| 1 | /*
|
|---|
| 2 | Unix SMB/CIFS implementation.
|
|---|
| 3 | Samba utility functions
|
|---|
| 4 | Copyright (C) Andrew Tridgell 1992-1998
|
|---|
| 5 | Copyright (C) Tim Potter 2000-2001
|
|---|
| 6 |
|
|---|
| 7 | This program is free software; you can redistribute it and/or modify
|
|---|
| 8 | it under the terms of the GNU General Public License as published by
|
|---|
| 9 | the Free Software Foundation; either version 3 of the License, or
|
|---|
| 10 | (at your option) any later version.
|
|---|
| 11 |
|
|---|
| 12 | This program is distributed in the hope that it will be useful,
|
|---|
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 15 | GNU General Public License for more details.
|
|---|
| 16 |
|
|---|
| 17 | You should have received a copy of the GNU General Public License
|
|---|
| 18 | along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|---|
| 19 | */
|
|---|
| 20 |
|
|---|
| 21 | #include "includes.h"
|
|---|
| 22 |
|
|---|
| 23 | /*******************************************************************
|
|---|
| 24 | this is like socketpair but uses tcp. It is used by the Samba
|
|---|
| 25 | regression test code
|
|---|
| 26 | The function guarantees that nobody else can attach to the socket,
|
|---|
| 27 | or if they do that this function fails and the socket gets closed
|
|---|
| 28 | returns 0 on success, -1 on failure
|
|---|
| 29 | the resulting file descriptors are symmetrical
|
|---|
| 30 | ******************************************************************/
|
|---|
| 31 | static int socketpair_tcp(int fd[2])
|
|---|
| 32 | {
|
|---|
| 33 | int listener;
|
|---|
| 34 | struct sockaddr_in sock;
|
|---|
| 35 | struct sockaddr_in sock2;
|
|---|
| 36 | socklen_t socklen = sizeof(sock);
|
|---|
| 37 | int connect_done = 0;
|
|---|
| 38 |
|
|---|
|
|---|