2
+----------------------------------------------------------------------+
4
+----------------------------------------------------------------------+
5
| Copyright (c) 1997-2004 The PHP Group |
6
+----------------------------------------------------------------------+
7
| This source file is subject to version 3.0 of the PHP license, |
8
| that is bundled with this package in the file LICENSE, and is |
9
| available through the world-wide-web at the following url: |
10
| http://www.php.net/license/3_0.txt. |
11
| If you did not receive a copy of the PHP license and are unable to |
12
| obtain it through the world-wide-web, please send a note to |
13
| license@php.net so we can mail you a copy immediately. |
14
+----------------------------------------------------------------------+
15
| Authors: Chris Vandomelen <chrisv@b0rked.dhs.org> |
16
| Sterling Hughes <sterling@php.net> |
18
| WinSock: Daniel Beulshausen <daniel@php4win.de> |
19
+----------------------------------------------------------------------+
22
/* $Id: php_sockets_win.c,v 1.11 2004/01/08 08:17:27 andi Exp $ */
31
#include "php_sockets.h"
32
#include "php_sockets_win.h"
34
int socketpair(int domain, int type, int protocol, SOCKET sock[2]) {
35
struct sockaddr_in address;
37
int size = sizeof(address);
39
if(domain != AF_INET) {
40
set_errno(WSAENOPROTOOPT);
45
sock[0] = socket(domain, type, protocol);
46
address.sin_addr.s_addr = INADDR_ANY;
47
address.sin_family = AF_INET;
50
bind(sock[0], (struct sockaddr*)&address, sizeof(address));
51
if(getsockname(sock[0], (struct sockaddr *)&address, &size) != 0) {
56
sock[1] = socket(domain, type, protocol);
57
address.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
59
connect(sock[1], (struct sockaddr*)&address, sizeof(address));
60
redirect = accept(sock[0],(struct sockaddr*)&address, &size);
65
if(sock[0] == INVALID_SOCKET ) {
68
set_errno(WSAECONNABORTED);
75
int inet_aton(const char *cp, struct in_addr *inp) {
76
inp->s_addr = inet_addr(cp);
78
if (inp->s_addr == INADDR_NONE) {
85
int fcntl(int fd, int cmd, ...) {
100
io = va_arg(va, int);
101
mode = io == O_NONBLOCK ? 1 : 0;
102
retval = ioctlsocket(fd, io, &mode);