105 |
"Open a socket on PORT and return (cons fd portname) where file \ |
"Open a socket on PORT and return (cons fd portname) where file \ |
106 |
descriptor is a small fixnum which is the write file descriptor for \ |
descriptor is a small fixnum which is the write file descriptor for \ |
107 |
the socket. If PORT is zero do automatic allocation of port") |
the socket. If PORT is zero do automatic allocation of port") |
108 |
{ int s, n, rc; struct |
{ |
109 |
sockaddr_in addr; |
#ifdef __MINGW32__ |
110 |
|
SOCKET s; |
111 |
|
#else |
112 |
|
int s; |
113 |
|
#endif |
114 |
|
int n, rc; |
115 |
|
struct sockaddr_in addr; |
116 |
|
|
117 |
#ifdef __MINGW32__ |
#ifdef __MINGW32__ |
118 |
if ( w32_socket_init() < 0 ) { |
if ( w32_socket_init() < 0 ) { |
123 |
|
|
124 |
/* Using TCP layer */ |
/* Using TCP layer */ |
125 |
s = socket(PF_INET, SOCK_STREAM, 0); |
s = socket(PF_INET, SOCK_STREAM, 0); |
126 |
|
#ifdef __MINGW32__ |
127 |
|
if ( s == INVALID_SOCKET ) |
128 |
|
#else |
129 |
if (s < 0) |
if (s < 0) |
130 |
|
#endif |
131 |
{ |
{ |
132 |
perror("ERROR !!! socket creation failed in sock_connect_to_name\n"); |
perror("ERROR !!! socket creation failed in sock_connect_to_name\n"); |
133 |
return Cnil; |
return Cnil; |
185 |
return Cnil; |
return Cnil; |
186 |
} |
} |
187 |
|
|
188 |
return make_cons(make_fixnum(s), small_fixnum(ntohs(addr.sin_port))); |
return make_cons(make_fixnum(s), make_fixnum(ntohs(addr.sin_port))); |
189 |
} |
} |
190 |
|
|
191 |
DEFUN_NEW("CLOSE-FD",object,fSclose_fd,SI,1,1,NONE,OI,OO,OO,OO,(fixnum fd), |
DEFUN_NEW("CLOSE-FD",object,fSclose_fd,SI,1,1,NONE,OI,OO,OO,OO,(fixnum fd), |