2 * sockets.c: Socket handles
5 * Dick Porter (dick@ximian.com)
7 * (C) 2002 Ximian, Inc.
15 #include <sys/types.h>
16 #include <sys/socket.h>
17 #include <sys/ioctl.h>
18 #ifdef HAVE_SYS_FILIO_H
19 #include <sys/filio.h> /* defines FIONBIO and FIONREAD */
21 #ifdef HAVE_SYS_SOCKIO_H
22 #include <sys/sockio.h> /* defines SIOCATMARK */
27 #ifndef HAVE_MSG_NOSIGNAL
31 #include <mono/io-layer/wapi.h>
32 #include <mono/io-layer/wapi-private.h>
33 #include <mono/io-layer/socket-private.h>
34 #include <mono/io-layer/handles-private.h>
35 #include <mono/io-layer/socket-wrappers.h>
39 static guint32 startup_count=0;
40 static GPtrArray *sockets=NULL;
41 static pthread_key_t error_key;
42 static mono_once_t error_key_once=MONO_ONCE_INIT;
44 static void socket_close_private (gpointer handle);
46 struct _WapiHandleOps _wapi_socket_ops = {
47 NULL, /* close_shared */
48 socket_close_private, /* close_private */
54 static mono_once_t socket_ops_once=MONO_ONCE_INIT;
56 static void socket_ops_init (void)
58 /* No capabilities to register */
61 static void socket_close_private (gpointer handle)
63 struct _WapiHandlePrivate_socket *socket_private_handle;
68 g_message(G_GNUC_PRETTY_FUNCTION ": closing socket handle %p",
72 if(startup_count==0) {
73 WSASetLastError(WSANOTINITIALISED);
77 ok=_wapi_lookup_handle (GUINT_TO_POINTER (handle), WAPI_HANDLE_SOCKET,
78 NULL, (gpointer *)&socket_private_handle);
80 g_warning (G_GNUC_PRETTY_FUNCTION
81 ": error looking up socket handle %p", handle);
82 WSASetLastError(WSAENOTSOCK);
86 g_ptr_array_remove_fast(sockets, GUINT_TO_POINTER (handle));
88 ret=close(socket_private_handle->fd);
92 g_message(G_GNUC_PRETTY_FUNCTION ": close error: %s",
95 errnum = errno_to_WSA (errnum, G_GNUC_PRETTY_FUNCTION);
96 WSASetLastError (errnum);
102 int WSAStartup(guint32 requested, WapiWSAData *data)
108 /* Insist on v2.0+ */
109 if(requested < MAKEWORD(2,0)) {
110 return(WSAVERNOTSUPPORTED);
113 if(startup_count==0) {
114 sockets=g_ptr_array_new();
119 /* I've no idea what is the minor version of the spec I read */
120 data->wHighVersion=MAKEWORD(2,0);
122 data->wVersion=requested < data->wHighVersion? requested:
126 g_message(G_GNUC_PRETTY_FUNCTION ": high version 0x%x",
130 strncpy(data->szDescription, "WAPI", WSADESCRIPTION_LEN);
131 strncpy(data->szSystemStatus, "groovy", WSASYS_STATUS_LEN);
141 g_message(G_GNUC_PRETTY_FUNCTION ": cleaning up");
144 if(--startup_count) {
149 /* Close down all sockets */
150 for(i=0; i<sockets->len; i++) {
153 handle=g_ptr_array_index(sockets, i);
154 _wapi_handle_ops_close_private (handle);
157 g_ptr_array_free(sockets, FALSE);
163 static void error_init(void)
165 pthread_key_create(&error_key, NULL);
168 void WSASetLastError(int error)
170 mono_once(&error_key_once, error_init);
171 pthread_setspecific(error_key, GINT_TO_POINTER(error));
174 int WSAGetLastError(void)
179 mono_once(&error_key_once, error_init);
180 errptr=pthread_getspecific(error_key);
181 err=GPOINTER_TO_INT(errptr);
186 int closesocket(guint32 handle)
188 _wapi_handle_unref (GUINT_TO_POINTER (handle));
192 guint32 _wapi_accept(guint32 handle, struct sockaddr *addr,
195 struct _WapiHandlePrivate_socket *socket_private_handle;
196 struct _WapiHandlePrivate_socket *new_socket_private_handle;
201 if(startup_count==0) {
202 WSASetLastError(WSANOTINITIALISED);
203 return(INVALID_SOCKET);
206 ok=_wapi_lookup_handle (GUINT_TO_POINTER (handle), WAPI_HANDLE_SOCKET,
207 NULL, (gpointer *)&socket_private_handle);
209 g_warning (G_GNUC_PRETTY_FUNCTION
210 ": error looking up socket handle 0x%x", handle);
211 WSASetLastError(WSAENOTSOCK);
212 return(INVALID_SOCKET);
215 fd=accept(socket_private_handle->fd, addr, addrlen);
219 g_message(G_GNUC_PRETTY_FUNCTION ": accept error: %s",
223 errnum = errno_to_WSA (errnum, G_GNUC_PRETTY_FUNCTION);
224 WSASetLastError (errnum);
226 return(INVALID_SOCKET);
229 new_handle=_wapi_handle_new (WAPI_HANDLE_SOCKET);
230 if(new_handle==_WAPI_HANDLE_INVALID) {
231 g_warning (G_GNUC_PRETTY_FUNCTION
232 ": error creating socket handle");
233 return(INVALID_SOCKET);
236 _wapi_handle_lock_handle (new_handle);
238 ok=_wapi_lookup_handle (new_handle, WAPI_HANDLE_SOCKET, NULL,
239 (gpointer *)&new_socket_private_handle);
241 g_warning (G_GNUC_PRETTY_FUNCTION
242 ": error looking up socket handle 0x%x", handle);
243 _wapi_handle_unlock_handle (new_handle);
244 return(INVALID_SOCKET);
247 new_socket_private_handle->fd=fd;
250 g_message(G_GNUC_PRETTY_FUNCTION
251 ": returning newly accepted socket handle %p with fd %d",
252 new_handle, new_socket_private_handle->fd);
255 _wapi_handle_unlock_handle (new_handle);
257 return(GPOINTER_TO_UINT (new_handle));
260 int _wapi_bind(guint32 handle, struct sockaddr *my_addr, socklen_t addrlen)
262 struct _WapiHandlePrivate_socket *socket_private_handle;
266 if(startup_count==0) {
267 WSASetLastError(WSANOTINITIALISED);
268 return(SOCKET_ERROR);
271 ok=_wapi_lookup_handle (GUINT_TO_POINTER (handle), WAPI_HANDLE_SOCKET,
272 NULL, (gpointer *)&socket_private_handle);
274 g_warning (G_GNUC_PRETTY_FUNCTION
275 ": error looking up socket handle 0x%x", handle);
276 WSASetLastError(WSAENOTSOCK);
277 return(SOCKET_ERROR);
280 ret=bind(socket_private_handle->fd, my_addr, addrlen);
284 g_message(G_GNUC_PRETTY_FUNCTION ": bind error: %s",
287 errnum = errno_to_WSA (errnum, G_GNUC_PRETTY_FUNCTION);
288 WSASetLastError (errnum);
290 return(SOCKET_ERROR);
295 int _wapi_connect(guint32 handle, const struct sockaddr *serv_addr,
298 struct _WapiHandlePrivate_socket *socket_private_handle;
303 if(startup_count==0) {
304 WSASetLastError(WSANOTINITIALISED);
305 return(SOCKET_ERROR);
308 ok=_wapi_lookup_handle (GUINT_TO_POINTER (handle), WAPI_HANDLE_SOCKET,
309 NULL, (gpointer *)&socket_private_handle);
311 g_warning (G_GNUC_PRETTY_FUNCTION
312 ": error looking up socket handle 0x%x", handle);
313 WSASetLastError(WSAENOTSOCK);
314 return(SOCKET_ERROR);
317 ret=connect(socket_private_handle->fd, serv_addr, addrlen);
318 if(ret==-1 && errno==EACCES) {
319 /* Try setting SO_BROADCAST and connecting again, but
320 * keep the original errno
326 ret=setsockopt (socket_private_handle->fd, SOL_SOCKET,
327 SO_BROADCAST, &true, sizeof(true));
329 ret=connect (socket_private_handle->fd, serv_addr,
332 } else if (ret==-1) {
338 g_message(G_GNUC_PRETTY_FUNCTION ": connect error: %s",
341 errnum = errno_to_WSA (errnum, G_GNUC_PRETTY_FUNCTION);
342 WSASetLastError (errnum);
344 return(SOCKET_ERROR);
349 int _wapi_getpeername(guint32 handle, struct sockaddr *name,
352 struct _WapiHandlePrivate_socket *socket_private_handle;
356 if(startup_count==0) {
357 WSASetLastError(WSANOTINITIALISED);
358 return(SOCKET_ERROR);
361 ok=_wapi_lookup_handle (GUINT_TO_POINTER (handle), WAPI_HANDLE_SOCKET,
362 NULL, (gpointer *)&socket_private_handle);
364 g_warning (G_GNUC_PRETTY_FUNCTION
365 ": error looking up socket handle 0x%x", handle);
366 WSASetLastError(WSAENOTSOCK);
367 return(SOCKET_ERROR);
370 ret=getpeername(socket_private_handle->fd, name, namelen);
374 g_message(G_GNUC_PRETTY_FUNCTION ": getpeername error: %s",
378 errnum = errno_to_WSA (errnum, G_GNUC_PRETTY_FUNCTION);
379 WSASetLastError (errnum);
381 return(SOCKET_ERROR);
387 int _wapi_getsockname(guint32 handle, struct sockaddr *name,
390 struct _WapiHandlePrivate_socket *socket_private_handle;
394 if(startup_count==0) {
395 WSASetLastError(WSANOTINITIALISED);
396 return(SOCKET_ERROR);
399 ok=_wapi_lookup_handle (GUINT_TO_POINTER (handle), WAPI_HANDLE_SOCKET,
400 NULL, (gpointer *)&socket_private_handle);
402 g_warning (G_GNUC_PRETTY_FUNCTION
403 ": error looking up socket handle 0x%x", handle);
404 WSASetLastError(WSAENOTSOCK);
405 return(SOCKET_ERROR);
408 ret=getsockname(socket_private_handle->fd, name, namelen);
412 g_message(G_GNUC_PRETTY_FUNCTION ": getsockname error: %s",
416 errnum = errno_to_WSA (errnum, G_GNUC_PRETTY_FUNCTION);
417 WSASetLastError (errnum);
419 return(SOCKET_ERROR);
425 int _wapi_getsockopt(guint32 handle, int level, int optname, void *optval,
428 struct _WapiHandlePrivate_socket *socket_private_handle;
432 if(startup_count==0) {
433 WSASetLastError(WSANOTINITIALISED);
434 return(SOCKET_ERROR);
437 ok=_wapi_lookup_handle (GUINT_TO_POINTER (handle), WAPI_HANDLE_SOCKET,
438 NULL, (gpointer *)&socket_private_handle);
440 g_warning (G_GNUC_PRETTY_FUNCTION
441 ": error looking up socket handle 0x%x", handle);
442 WSASetLastError(WSAENOTSOCK);
443 return(SOCKET_ERROR);
446 ret=getsockopt(socket_private_handle->fd, level, optname, optval,
451 g_message(G_GNUC_PRETTY_FUNCTION ": getsockopt error: %s",
455 errnum = errno_to_WSA (errnum, G_GNUC_PRETTY_FUNCTION);
456 WSASetLastError (errnum);
458 return(SOCKET_ERROR);
464 int _wapi_listen(guint32 handle, int backlog)
466 struct _WapiHandlePrivate_socket *socket_private_handle;
470 if(startup_count==0) {
471 WSASetLastError(WSANOTINITIALISED);
472 return(SOCKET_ERROR);
475 ok=_wapi_lookup_handle (GUINT_TO_POINTER (handle), WAPI_HANDLE_SOCKET,
476 NULL, (gpointer *)&socket_private_handle);
478 g_warning (G_GNUC_PRETTY_FUNCTION
479 ": error looking up socket handle 0x%x", handle);
480 WSASetLastError(WSAENOTSOCK);
481 return(SOCKET_ERROR);
484 ret=listen(socket_private_handle->fd, backlog);
488 g_message(G_GNUC_PRETTY_FUNCTION ": listen error: %s",
492 errnum = errno_to_WSA (errnum, G_GNUC_PRETTY_FUNCTION);
493 WSASetLastError (errnum);
495 return(SOCKET_ERROR);
501 int _wapi_recv(guint32 handle, void *buf, size_t len, int recv_flags)
503 return(_wapi_recvfrom(handle, buf, len, recv_flags, NULL, 0));
506 int _wapi_recvfrom(guint32 handle, void *buf, size_t len, int recv_flags,
507 struct sockaddr *from, socklen_t *fromlen)
509 #ifndef HAVE_MSG_NOSIGNAL
510 void (*old_sigpipe)(int); // old SIGPIPE handler
512 struct _WapiHandlePrivate_socket *socket_private_handle;
516 if(startup_count==0) {
517 WSASetLastError(WSANOTINITIALISED);
518 return(SOCKET_ERROR);
521 ok=_wapi_lookup_handle (GUINT_TO_POINTER (handle), WAPI_HANDLE_SOCKET,
522 NULL, (gpointer *)&socket_private_handle);
524 g_warning (G_GNUC_PRETTY_FUNCTION
525 ": error looking up socket handle 0x%x", handle);
526 WSASetLastError(WSAENOTSOCK);
527 return(SOCKET_ERROR);
530 #ifdef HAVE_MSG_NOSIGNAL
531 ret=recvfrom(socket_private_handle->fd, buf, len, recv_flags | MSG_NOSIGNAL, from,
534 old_sigpipe = signal(SIGPIPE, SIG_IGN);
535 ret=recvfrom(socket_private_handle->fd, buf, len, recv_flags, from,
537 signal(SIGPIPE, old_sigpipe);
543 g_message(G_GNUC_PRETTY_FUNCTION ": recv error: %s",
547 errnum = errno_to_WSA (errnum, G_GNUC_PRETTY_FUNCTION);
548 WSASetLastError (errnum);
550 return(SOCKET_ERROR);
555 int _wapi_send(guint32 handle, const void *msg, size_t len, int send_flags)
557 #ifndef HAVE_MSG_NOSIGNAL
558 void (*old_sigpipe)(int); // old SIGPIPE handler
560 struct _WapiHandlePrivate_socket *socket_private_handle;
564 if(startup_count==0) {
565 WSASetLastError(WSANOTINITIALISED);
566 return(SOCKET_ERROR);
569 ok=_wapi_lookup_handle (GUINT_TO_POINTER (handle), WAPI_HANDLE_SOCKET,
570 NULL, (gpointer *)&socket_private_handle);
572 g_warning (G_GNUC_PRETTY_FUNCTION
573 ": error looking up socket handle 0x%x", handle);
574 WSASetLastError(WSAENOTSOCK);
575 return(SOCKET_ERROR);
578 #ifdef HAVE_MSG_NOSIGNAL
579 ret=send(socket_private_handle->fd, msg, len, send_flags | MSG_NOSIGNAL);
581 old_sigpipe = signal(SIGPIPE, SIG_IGN);
582 ret=send(socket_private_handle->fd, msg, len, send_flags);
583 signal(SIGPIPE, old_sigpipe);
588 g_message(G_GNUC_PRETTY_FUNCTION ": send error: %s",
592 errnum = errno_to_WSA (errnum, G_GNUC_PRETTY_FUNCTION);
593 WSASetLastError (errnum);
595 return(SOCKET_ERROR);
600 int _wapi_sendto(guint32 handle, const void *msg, size_t len, int send_flags,
601 const struct sockaddr *to, socklen_t tolen)
603 #ifndef HAVE_MSG_NOSIGNAL
604 void (*old_sigpipe)(int); // old SIGPIPE handler
606 struct _WapiHandlePrivate_socket *socket_private_handle;
610 if(startup_count==0) {
611 WSASetLastError(WSANOTINITIALISED);
612 return(SOCKET_ERROR);
615 ok=_wapi_lookup_handle (GUINT_TO_POINTER (handle), WAPI_HANDLE_SOCKET,
616 NULL, (gpointer *)&socket_private_handle);
618 g_warning (G_GNUC_PRETTY_FUNCTION
619 ": error looking up socket handle 0x%x", handle);
620 WSASetLastError(WSAENOTSOCK);
621 return(SOCKET_ERROR);
624 #ifdef HAVE_MSG_NOSIGNAL
625 ret=sendto(socket_private_handle->fd, msg, len, send_flags | MSG_NOSIGNAL, to, tolen);
627 old_sigpipe = signal(SIGPIPE, SIG_IGN);
628 ret=sendto(socket_private_handle->fd, msg, len, send_flags, to, tolen);
629 signal(SIGPIPE, old_sigpipe);
634 g_message(G_GNUC_PRETTY_FUNCTION ": send error: %s",
638 errnum = errno_to_WSA (errnum, G_GNUC_PRETTY_FUNCTION);
639 WSASetLastError (errnum);
641 return(SOCKET_ERROR);
646 int _wapi_setsockopt(guint32 handle, int level, int optname,
647 const void *optval, socklen_t optlen)
649 struct _WapiHandlePrivate_socket *socket_private_handle;
653 if(startup_count==0) {
654 WSASetLastError(WSANOTINITIALISED);
655 return(SOCKET_ERROR);
658 ok=_wapi_lookup_handle (GUINT_TO_POINTER (handle), WAPI_HANDLE_SOCKET,
659 NULL, (gpointer *)&socket_private_handle);
661 g_warning (G_GNUC_PRETTY_FUNCTION
662 ": error looking up socket handle 0x%x", handle);
663 WSASetLastError(WSAENOTSOCK);
664 return(SOCKET_ERROR);
667 ret=setsockopt(socket_private_handle->fd, level, optname, optval,
672 g_message(G_GNUC_PRETTY_FUNCTION ": setsockopt error: %s",
676 errnum = errno_to_WSA (errnum, G_GNUC_PRETTY_FUNCTION);
677 WSASetLastError (errnum);
679 return(SOCKET_ERROR);
685 int _wapi_shutdown(guint32 handle, int how)
687 struct _WapiHandlePrivate_socket *socket_private_handle;
691 if(startup_count==0) {
692 WSASetLastError(WSANOTINITIALISED);
693 return(SOCKET_ERROR);
696 ok=_wapi_lookup_handle (GUINT_TO_POINTER (handle), WAPI_HANDLE_SOCKET,
697 NULL, (gpointer *)&socket_private_handle);
699 g_warning (G_GNUC_PRETTY_FUNCTION
700 ": error looking up socket handle 0x%x", handle);
701 WSASetLastError(WSAENOTSOCK);
702 return(SOCKET_ERROR);
705 ret=shutdown(socket_private_handle->fd, how);
709 g_message(G_GNUC_PRETTY_FUNCTION ": shutdown error: %s",
713 errnum = errno_to_WSA (errnum, G_GNUC_PRETTY_FUNCTION);
714 WSASetLastError (errnum);
716 return(SOCKET_ERROR);
722 guint32 _wapi_socket(int domain, int type, int protocol)
724 struct _WapiHandlePrivate_socket *socket_private_handle;
729 fd=socket(domain, type, protocol);
733 g_message(G_GNUC_PRETTY_FUNCTION ": socket error: %s", strerror(errno));
735 errnum = errno_to_WSA (errnum, G_GNUC_PRETTY_FUNCTION);
736 WSASetLastError (errnum);
738 return(INVALID_SOCKET);
741 mono_once (&socket_ops_once, socket_ops_init);
743 handle=_wapi_handle_new (WAPI_HANDLE_SOCKET);
744 if(handle==_WAPI_HANDLE_INVALID) {
745 g_warning (G_GNUC_PRETTY_FUNCTION
746 ": error creating socket handle");
747 return(INVALID_SOCKET);
750 _wapi_handle_lock_handle (handle);
752 ok=_wapi_lookup_handle (handle, WAPI_HANDLE_SOCKET, NULL,
753 (gpointer *)&socket_private_handle);
755 g_warning (G_GNUC_PRETTY_FUNCTION
756 ": error looking up socket handle %p", handle);
757 _wapi_handle_unlock_handle (handle);
758 return(INVALID_SOCKET);
761 socket_private_handle->fd=fd;
764 g_message(G_GNUC_PRETTY_FUNCTION
765 ": returning socket handle %p with fd %d", handle,
766 socket_private_handle->fd);
769 _wapi_handle_unlock_handle (handle);
771 return(GPOINTER_TO_UINT (handle));
774 struct hostent *_wapi_gethostbyname(const char *hostname)
778 if(startup_count==0) {
779 WSASetLastError(WSANOTINITIALISED);
783 he=gethostbyname(hostname);
786 g_message(G_GNUC_PRETTY_FUNCTION ": gethostbyname error: %s",
792 WSASetLastError(WSAHOST_NOT_FOUND);
794 #if NO_ADDRESS != NO_DATA
798 WSASetLastError(WSANO_DATA);
801 WSASetLastError(WSANO_RECOVERY);
804 WSASetLastError(WSATRY_AGAIN);
807 g_warning (G_GNUC_PRETTY_FUNCTION ": Need to translate %d into winsock error", h_errno);
815 int ioctlsocket(guint32 handle, gint32 command, gpointer arg)
817 struct _WapiHandlePrivate_socket *socket_private_handle;
821 if(startup_count==0) {
822 WSASetLastError(WSANOTINITIALISED);
823 return(SOCKET_ERROR);
826 ok=_wapi_lookup_handle (GUINT_TO_POINTER (handle), WAPI_HANDLE_SOCKET,
827 NULL, (gpointer *)&socket_private_handle);
829 g_warning (G_GNUC_PRETTY_FUNCTION
830 ": error looking up socket handle 0x%x", handle);
831 WSASetLastError(WSAENOTSOCK);
832 return(SOCKET_ERROR);
835 if(command!=FIONBIO &&
837 command!=SIOCATMARK) {
838 /* Not listed in the MSDN specs, but ioctl(2) returns
839 * this if command is invalid
841 WSASetLastError(WSAEINVAL);
842 return(SOCKET_ERROR);
846 /* This works better than ioctl(...FIONBIO...) on Linux (it causes
847 * connect to return EINPROGRESS, but the ioctl doesn't seem to)
849 if(command==FIONBIO) {
850 ret=fcntl(socket_private_handle->fd, F_GETFL, 0);
852 if(*(gboolean *)arg) {
857 ret=fcntl(socket_private_handle->fd, F_SETFL, ret);
860 #endif /* O_NONBLOCK */
862 ret=ioctl(socket_private_handle->fd, command, arg);
867 g_message(G_GNUC_PRETTY_FUNCTION ": ioctl error: %s",
871 errnum = errno_to_WSA (errnum, G_GNUC_PRETTY_FUNCTION);
872 WSASetLastError (errnum);
874 return(SOCKET_ERROR);
880 int _wapi_select(int nfds G_GNUC_UNUSED, fd_set *readfds, fd_set *writefds,
881 fd_set *exceptfds, struct timeval *timeout)
885 if(startup_count==0) {
886 WSASetLastError(WSANOTINITIALISED);
887 return(SOCKET_ERROR);
890 ret=select(getdtablesize(), readfds, writefds, exceptfds, timeout);
894 g_message(G_GNUC_PRETTY_FUNCTION ": select error: %s",
897 errnum = errno_to_WSA (errnum, G_GNUC_PRETTY_FUNCTION);
898 WSASetLastError (errnum);
900 return(SOCKET_ERROR);
906 void _wapi_FD_CLR(guint32 handle, fd_set *set)
908 struct _WapiHandlePrivate_socket *socket_private_handle;
911 ok=_wapi_lookup_handle (GUINT_TO_POINTER (handle), WAPI_HANDLE_SOCKET,
912 NULL, (gpointer *)&socket_private_handle);
914 g_warning (G_GNUC_PRETTY_FUNCTION
915 ": error looking up socket handle 0x%x", handle);
916 WSASetLastError(WSAENOTSOCK);
920 FD_CLR(socket_private_handle->fd, set);
923 int _wapi_FD_ISSET(guint32 handle, fd_set *set)
925 struct _WapiHandlePrivate_socket *socket_private_handle;
928 ok=_wapi_lookup_handle (GUINT_TO_POINTER (handle), WAPI_HANDLE_SOCKET,
929 NULL, (gpointer *)&socket_private_handle);
931 g_warning (G_GNUC_PRETTY_FUNCTION
932 ": error looking up socket handle 0x%x", handle);
933 WSASetLastError(WSAENOTSOCK);
937 return(FD_ISSET(socket_private_handle->fd, set));
940 void _wapi_FD_SET(guint32 handle, fd_set *set)
942 struct _WapiHandlePrivate_socket *socket_private_handle;
945 ok=_wapi_lookup_handle (GUINT_TO_POINTER (handle), WAPI_HANDLE_SOCKET,
946 NULL, (gpointer *)&socket_private_handle);
948 g_warning (G_GNUC_PRETTY_FUNCTION
949 ": error looking up socket handle 0x%x", handle);
950 WSASetLastError(WSAENOTSOCK);
954 FD_SET(socket_private_handle->fd, set);