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>
38 static guint32 startup_count=0;
39 static GPtrArray *sockets=NULL;
40 static pthread_key_t error_key;
41 static mono_once_t error_key_once=MONO_ONCE_INIT;
43 static void socket_close_private (gpointer handle);
45 struct _WapiHandleOps _wapi_socket_ops = {
46 NULL, /* close_shared */
47 socket_close_private, /* close_private */
53 static mono_once_t socket_ops_once=MONO_ONCE_INIT;
55 static void socket_ops_init (void)
57 /* No capabilities to register */
60 static void socket_close_private (gpointer handle)
62 struct _WapiHandlePrivate_socket *socket_private_handle;
67 g_message(G_GNUC_PRETTY_FUNCTION ": closing socket handle %p",
71 if(startup_count==0) {
72 WSASetLastError(WSANOTINITIALISED);
76 ok=_wapi_lookup_handle (GUINT_TO_POINTER (handle), WAPI_HANDLE_SOCKET,
77 NULL, (gpointer *)&socket_private_handle);
79 g_warning (G_GNUC_PRETTY_FUNCTION
80 ": error looking up socket handle %p", handle);
81 WSASetLastError(WSAENOTSOCK);
85 g_ptr_array_remove_fast(sockets, GUINT_TO_POINTER (handle));
87 ret=close(socket_private_handle->fd);
91 g_message(G_GNUC_PRETTY_FUNCTION ": close error: %s",
94 errnum = errno_to_WSA (errnum, G_GNUC_PRETTY_FUNCTION);
95 WSASetLastError (errnum);
101 int WSAStartup(guint32 requested, WapiWSAData *data)
107 /* Insist on v2.0+ */
108 if(requested < MAKEWORD(2,0)) {
109 return(WSAVERNOTSUPPORTED);
112 if(startup_count==0) {
113 sockets=g_ptr_array_new();
118 /* I've no idea what is the minor version of the spec I read */
119 data->wHighVersion=MAKEWORD(2,0);
121 data->wVersion=requested < data->wHighVersion? requested:
125 g_message(G_GNUC_PRETTY_FUNCTION ": high version 0x%x",
129 strncpy(data->szDescription, "WAPI", WSADESCRIPTION_LEN);
130 strncpy(data->szSystemStatus, "groovy", WSASYS_STATUS_LEN);
140 g_message(G_GNUC_PRETTY_FUNCTION ": cleaning up");
143 if(--startup_count) {
148 /* Close down all sockets */
149 for(i=0; i<sockets->len; i++) {
152 handle=g_ptr_array_index(sockets, i);
153 _wapi_handle_ops_close_private (handle);
156 g_ptr_array_free(sockets, FALSE);
162 static void error_init(void)
164 pthread_key_create(&error_key, NULL);
167 void WSASetLastError(int error)
169 mono_once(&error_key_once, error_init);
170 pthread_setspecific(error_key, GINT_TO_POINTER(error));
173 int WSAGetLastError(void)
178 mono_once(&error_key_once, error_init);
179 errptr=pthread_getspecific(error_key);
180 err=GPOINTER_TO_INT(errptr);
185 int closesocket(guint32 handle)
187 _wapi_handle_unref (GUINT_TO_POINTER (handle));
191 guint32 _wapi_accept(guint32 handle, struct sockaddr *addr,
194 struct _WapiHandlePrivate_socket *socket_private_handle;
195 struct _WapiHandlePrivate_socket *new_socket_private_handle;
200 if(startup_count==0) {
201 WSASetLastError(WSANOTINITIALISED);
202 return(INVALID_SOCKET);
205 ok=_wapi_lookup_handle (GUINT_TO_POINTER (handle), WAPI_HANDLE_SOCKET,
206 NULL, (gpointer *)&socket_private_handle);
208 g_warning (G_GNUC_PRETTY_FUNCTION
209 ": error looking up socket handle 0x%x", handle);
210 WSASetLastError(WSAENOTSOCK);
211 return(INVALID_SOCKET);
214 fd=accept(socket_private_handle->fd, addr, addrlen);
218 g_message(G_GNUC_PRETTY_FUNCTION ": accept error: %s",
222 errnum = errno_to_WSA (errnum, G_GNUC_PRETTY_FUNCTION);
223 WSASetLastError (errnum);
225 return(INVALID_SOCKET);
228 new_handle=_wapi_handle_new (WAPI_HANDLE_SOCKET);
229 if(new_handle==_WAPI_HANDLE_INVALID) {
230 g_warning (G_GNUC_PRETTY_FUNCTION
231 ": error creating socket handle");
232 return(INVALID_SOCKET);
235 _wapi_handle_lock_handle (new_handle);
237 ok=_wapi_lookup_handle (new_handle, WAPI_HANDLE_SOCKET, NULL,
238 (gpointer *)&new_socket_private_handle);
240 g_warning (G_GNUC_PRETTY_FUNCTION
241 ": error looking up socket handle 0x%x", handle);
242 _wapi_handle_unlock_handle (new_handle);
243 return(INVALID_SOCKET);
246 new_socket_private_handle->fd=fd;
249 g_message(G_GNUC_PRETTY_FUNCTION
250 ": returning newly accepted socket handle %p with fd %d",
251 new_handle, new_socket_private_handle->fd);
254 _wapi_handle_unlock_handle (new_handle);
256 return(GPOINTER_TO_UINT (new_handle));
259 int _wapi_bind(guint32 handle, struct sockaddr *my_addr, socklen_t addrlen)
261 struct _WapiHandlePrivate_socket *socket_private_handle;
265 if(startup_count==0) {
266 WSASetLastError(WSANOTINITIALISED);
267 return(SOCKET_ERROR);
270 ok=_wapi_lookup_handle (GUINT_TO_POINTER (handle), WAPI_HANDLE_SOCKET,
271 NULL, (gpointer *)&socket_private_handle);
273 g_warning (G_GNUC_PRETTY_FUNCTION
274 ": error looking up socket handle 0x%x", handle);
275 WSASetLastError(WSAENOTSOCK);
276 return(SOCKET_ERROR);
279 ret=bind(socket_private_handle->fd, my_addr, addrlen);
283 g_message(G_GNUC_PRETTY_FUNCTION ": bind error: %s",
286 errnum = errno_to_WSA (errnum, G_GNUC_PRETTY_FUNCTION);
287 WSASetLastError (errnum);
289 return(SOCKET_ERROR);
294 int _wapi_connect(guint32 handle, const struct sockaddr *serv_addr,
297 struct _WapiHandlePrivate_socket *socket_private_handle;
302 if(startup_count==0) {
303 WSASetLastError(WSANOTINITIALISED);
304 return(SOCKET_ERROR);
307 ok=_wapi_lookup_handle (GUINT_TO_POINTER (handle), WAPI_HANDLE_SOCKET,
308 NULL, (gpointer *)&socket_private_handle);
310 g_warning (G_GNUC_PRETTY_FUNCTION
311 ": error looking up socket handle 0x%x", handle);
312 WSASetLastError(WSAENOTSOCK);
313 return(SOCKET_ERROR);
316 ret=connect(socket_private_handle->fd, serv_addr, addrlen);
317 if(ret==-1 && errno==EACCES) {
318 /* Try setting SO_BROADCAST and connecting again, but
319 * keep the original errno
325 ret=setsockopt (socket_private_handle->fd, SOL_SOCKET,
326 SO_BROADCAST, &true, sizeof(true));
328 ret=connect (socket_private_handle->fd, serv_addr,
331 } else if (ret==-1) {
337 g_message(G_GNUC_PRETTY_FUNCTION ": connect error: %s",
340 errnum = errno_to_WSA (errnum, G_GNUC_PRETTY_FUNCTION);
341 WSASetLastError (errnum);
343 return(SOCKET_ERROR);
348 int _wapi_getpeername(guint32 handle, struct sockaddr *name,
351 struct _WapiHandlePrivate_socket *socket_private_handle;
355 if(startup_count==0) {
356 WSASetLastError(WSANOTINITIALISED);
357 return(SOCKET_ERROR);
360 ok=_wapi_lookup_handle (GUINT_TO_POINTER (handle), WAPI_HANDLE_SOCKET,
361 NULL, (gpointer *)&socket_private_handle);
363 g_warning (G_GNUC_PRETTY_FUNCTION
364 ": error looking up socket handle 0x%x", handle);
365 WSASetLastError(WSAENOTSOCK);
366 return(SOCKET_ERROR);
369 ret=getpeername(socket_private_handle->fd, name, namelen);
373 g_message(G_GNUC_PRETTY_FUNCTION ": getpeername error: %s",
377 errnum = errno_to_WSA (errnum, G_GNUC_PRETTY_FUNCTION);
378 WSASetLastError (errnum);
380 return(SOCKET_ERROR);
386 int _wapi_getsockname(guint32 handle, struct sockaddr *name,
389 struct _WapiHandlePrivate_socket *socket_private_handle;
393 if(startup_count==0) {
394 WSASetLastError(WSANOTINITIALISED);
395 return(SOCKET_ERROR);
398 ok=_wapi_lookup_handle (GUINT_TO_POINTER (handle), WAPI_HANDLE_SOCKET,
399 NULL, (gpointer *)&socket_private_handle);
401 g_warning (G_GNUC_PRETTY_FUNCTION
402 ": error looking up socket handle 0x%x", handle);
403 WSASetLastError(WSAENOTSOCK);
404 return(SOCKET_ERROR);
407 ret=getsockname(socket_private_handle->fd, name, namelen);
411 g_message(G_GNUC_PRETTY_FUNCTION ": getsockname error: %s",
415 errnum = errno_to_WSA (errnum, G_GNUC_PRETTY_FUNCTION);
416 WSASetLastError (errnum);
418 return(SOCKET_ERROR);
424 int _wapi_getsockopt(guint32 handle, int level, int optname, void *optval,
427 struct _WapiHandlePrivate_socket *socket_private_handle;
431 if(startup_count==0) {
432 WSASetLastError(WSANOTINITIALISED);
433 return(SOCKET_ERROR);
436 ok=_wapi_lookup_handle (GUINT_TO_POINTER (handle), WAPI_HANDLE_SOCKET,
437 NULL, (gpointer *)&socket_private_handle);
439 g_warning (G_GNUC_PRETTY_FUNCTION
440 ": error looking up socket handle 0x%x", handle);
441 WSASetLastError(WSAENOTSOCK);
442 return(SOCKET_ERROR);
445 ret=getsockopt(socket_private_handle->fd, level, optname, optval,
450 g_message(G_GNUC_PRETTY_FUNCTION ": getsockopt error: %s",
454 errnum = errno_to_WSA (errnum, G_GNUC_PRETTY_FUNCTION);
455 WSASetLastError (errnum);
457 return(SOCKET_ERROR);
463 int _wapi_listen(guint32 handle, int backlog)
465 struct _WapiHandlePrivate_socket *socket_private_handle;
469 if(startup_count==0) {
470 WSASetLastError(WSANOTINITIALISED);
471 return(SOCKET_ERROR);
474 ok=_wapi_lookup_handle (GUINT_TO_POINTER (handle), WAPI_HANDLE_SOCKET,
475 NULL, (gpointer *)&socket_private_handle);
477 g_warning (G_GNUC_PRETTY_FUNCTION
478 ": error looking up socket handle 0x%x", handle);
479 WSASetLastError(WSAENOTSOCK);
480 return(SOCKET_ERROR);
483 ret=listen(socket_private_handle->fd, backlog);
487 g_message(G_GNUC_PRETTY_FUNCTION ": listen error: %s",
491 errnum = errno_to_WSA (errnum, G_GNUC_PRETTY_FUNCTION);
492 WSASetLastError (errnum);
494 return(SOCKET_ERROR);
500 int _wapi_recv(guint32 handle, void *buf, size_t len, int recv_flags)
502 return(_wapi_recvfrom(handle, buf, len, recv_flags, NULL, 0));
505 int _wapi_recvfrom(guint32 handle, void *buf, size_t len, int recv_flags,
506 struct sockaddr *from, socklen_t *fromlen)
508 #ifndef HAVE_MSG_NOSIGNAL
509 void (*old_sigpipe)(int); // old SIGPIPE handler
511 struct _WapiHandlePrivate_socket *socket_private_handle;
515 if(startup_count==0) {
516 WSASetLastError(WSANOTINITIALISED);
517 return(SOCKET_ERROR);
520 ok=_wapi_lookup_handle (GUINT_TO_POINTER (handle), WAPI_HANDLE_SOCKET,
521 NULL, (gpointer *)&socket_private_handle);
523 g_warning (G_GNUC_PRETTY_FUNCTION
524 ": error looking up socket handle 0x%x", handle);
525 WSASetLastError(WSAENOTSOCK);
526 return(SOCKET_ERROR);
529 #ifdef HAVE_MSG_NOSIGNAL
530 ret=recvfrom(socket_private_handle->fd, buf, len, recv_flags | MSG_NOSIGNAL, from,
533 old_sigpipe = signal(SIGPIPE, SIG_IGN);
534 ret=recvfrom(socket_private_handle->fd, buf, len, recv_flags, from,
536 signal(SIGPIPE, old_sigpipe);
542 g_message(G_GNUC_PRETTY_FUNCTION ": recv error: %s",
546 errnum = errno_to_WSA (errnum, G_GNUC_PRETTY_FUNCTION);
547 WSASetLastError (errnum);
549 return(SOCKET_ERROR);
554 int _wapi_send(guint32 handle, const void *msg, size_t len, int send_flags)
556 #ifndef HAVE_MSG_NOSIGNAL
557 void (*old_sigpipe)(int); // old SIGPIPE handler
559 struct _WapiHandlePrivate_socket *socket_private_handle;
563 if(startup_count==0) {
564 WSASetLastError(WSANOTINITIALISED);
565 return(SOCKET_ERROR);
568 ok=_wapi_lookup_handle (GUINT_TO_POINTER (handle), WAPI_HANDLE_SOCKET,
569 NULL, (gpointer *)&socket_private_handle);
571 g_warning (G_GNUC_PRETTY_FUNCTION
572 ": error looking up socket handle 0x%x", handle);
573 WSASetLastError(WSAENOTSOCK);
574 return(SOCKET_ERROR);
577 #ifdef HAVE_MSG_NOSIGNAL
578 ret=send(socket_private_handle->fd, msg, len, send_flags | MSG_NOSIGNAL);
580 old_sigpipe = signal(SIGPIPE, SIG_IGN);
581 ret=send(socket_private_handle->fd, msg, len, send_flags);
582 signal(SIGPIPE, old_sigpipe);
587 g_message(G_GNUC_PRETTY_FUNCTION ": send error: %s",
591 errnum = errno_to_WSA (errnum, G_GNUC_PRETTY_FUNCTION);
592 WSASetLastError (errnum);
594 return(SOCKET_ERROR);
599 int _wapi_sendto(guint32 handle, const void *msg, size_t len, int send_flags,
600 const struct sockaddr *to, socklen_t tolen)
602 #ifndef HAVE_MSG_NOSIGNAL
603 void (*old_sigpipe)(int); // old SIGPIPE handler
605 struct _WapiHandlePrivate_socket *socket_private_handle;
609 if(startup_count==0) {
610 WSASetLastError(WSANOTINITIALISED);
611 return(SOCKET_ERROR);
614 ok=_wapi_lookup_handle (GUINT_TO_POINTER (handle), WAPI_HANDLE_SOCKET,
615 NULL, (gpointer *)&socket_private_handle);
617 g_warning (G_GNUC_PRETTY_FUNCTION
618 ": error looking up socket handle 0x%x", handle);
619 WSASetLastError(WSAENOTSOCK);
620 return(SOCKET_ERROR);
623 #ifdef HAVE_MSG_NOSIGNAL
624 ret=sendto(socket_private_handle->fd, msg, len, send_flags | MSG_NOSIGNAL, to, tolen);
626 old_sigpipe = signal(SIGPIPE, SIG_IGN);
627 ret=sendto(socket_private_handle->fd, msg, len, send_flags, to, tolen);
628 signal(SIGPIPE, old_sigpipe);
633 g_message(G_GNUC_PRETTY_FUNCTION ": send error: %s",
637 errnum = errno_to_WSA (errnum, G_GNUC_PRETTY_FUNCTION);
638 WSASetLastError (errnum);
640 return(SOCKET_ERROR);
645 int _wapi_setsockopt(guint32 handle, int level, int optname,
646 const void *optval, socklen_t optlen)
648 struct _WapiHandlePrivate_socket *socket_private_handle;
652 if(startup_count==0) {
653 WSASetLastError(WSANOTINITIALISED);
654 return(SOCKET_ERROR);
657 ok=_wapi_lookup_handle (GUINT_TO_POINTER (handle), WAPI_HANDLE_SOCKET,
658 NULL, (gpointer *)&socket_private_handle);
660 g_warning (G_GNUC_PRETTY_FUNCTION
661 ": error looking up socket handle 0x%x", handle);
662 WSASetLastError(WSAENOTSOCK);
663 return(SOCKET_ERROR);
666 ret=setsockopt(socket_private_handle->fd, level, optname, optval,
671 g_message(G_GNUC_PRETTY_FUNCTION ": setsockopt error: %s",
675 errnum = errno_to_WSA (errnum, G_GNUC_PRETTY_FUNCTION);
676 WSASetLastError (errnum);
678 return(SOCKET_ERROR);
684 int _wapi_shutdown(guint32 handle, int how)
686 struct _WapiHandlePrivate_socket *socket_private_handle;
690 if(startup_count==0) {
691 WSASetLastError(WSANOTINITIALISED);
692 return(SOCKET_ERROR);
695 ok=_wapi_lookup_handle (GUINT_TO_POINTER (handle), WAPI_HANDLE_SOCKET,
696 NULL, (gpointer *)&socket_private_handle);
698 g_warning (G_GNUC_PRETTY_FUNCTION
699 ": error looking up socket handle 0x%x", handle);
700 WSASetLastError(WSAENOTSOCK);
701 return(SOCKET_ERROR);
704 ret=shutdown(socket_private_handle->fd, how);
708 g_message(G_GNUC_PRETTY_FUNCTION ": shutdown error: %s",
712 errnum = errno_to_WSA (errnum, G_GNUC_PRETTY_FUNCTION);
713 WSASetLastError (errnum);
715 return(SOCKET_ERROR);
721 guint32 _wapi_socket(int domain, int type, int protocol)
723 struct _WapiHandlePrivate_socket *socket_private_handle;
728 fd=socket(domain, type, protocol);
732 g_message(G_GNUC_PRETTY_FUNCTION ": socket error: %s", strerror(errno));
734 errnum = errno_to_WSA (errnum, G_GNUC_PRETTY_FUNCTION);
735 WSASetLastError (errnum);
737 return(INVALID_SOCKET);
740 mono_once (&socket_ops_once, socket_ops_init);
742 handle=_wapi_handle_new (WAPI_HANDLE_SOCKET);
743 if(handle==_WAPI_HANDLE_INVALID) {
744 g_warning (G_GNUC_PRETTY_FUNCTION
745 ": error creating socket handle");
746 return(INVALID_SOCKET);
749 _wapi_handle_lock_handle (handle);
751 ok=_wapi_lookup_handle (handle, WAPI_HANDLE_SOCKET, NULL,
752 (gpointer *)&socket_private_handle);
754 g_warning (G_GNUC_PRETTY_FUNCTION
755 ": error looking up socket handle %p", handle);
756 _wapi_handle_unlock_handle (handle);
757 return(INVALID_SOCKET);
760 socket_private_handle->fd=fd;
763 g_message(G_GNUC_PRETTY_FUNCTION
764 ": returning socket handle %p with fd %d", handle,
765 socket_private_handle->fd);
768 _wapi_handle_unlock_handle (handle);
770 return(GPOINTER_TO_UINT (handle));
773 struct hostent *_wapi_gethostbyname(const char *hostname)
777 if(startup_count==0) {
778 WSASetLastError(WSANOTINITIALISED);
782 he=gethostbyname(hostname);
785 g_message(G_GNUC_PRETTY_FUNCTION ": gethostbyname error: %s",
791 WSASetLastError(WSAHOST_NOT_FOUND);
793 #if NO_ADDRESS != NO_DATA
797 WSASetLastError(WSANO_DATA);
800 WSASetLastError(WSANO_RECOVERY);
803 WSASetLastError(WSATRY_AGAIN);
806 g_warning (G_GNUC_PRETTY_FUNCTION ": Need to translate %d into winsock error", h_errno);
814 int ioctlsocket(guint32 handle, gint32 command, gpointer arg)
816 struct _WapiHandlePrivate_socket *socket_private_handle;
820 if(startup_count==0) {
821 WSASetLastError(WSANOTINITIALISED);
822 return(SOCKET_ERROR);
825 ok=_wapi_lookup_handle (GUINT_TO_POINTER (handle), WAPI_HANDLE_SOCKET,
826 NULL, (gpointer *)&socket_private_handle);
828 g_warning (G_GNUC_PRETTY_FUNCTION
829 ": error looking up socket handle 0x%x", handle);
830 WSASetLastError(WSAENOTSOCK);
831 return(SOCKET_ERROR);
834 if(command!=FIONBIO &&
836 command!=SIOCATMARK) {
837 /* Not listed in the MSDN specs, but ioctl(2) returns
838 * this if command is invalid
840 WSASetLastError(WSAEINVAL);
841 return(SOCKET_ERROR);
845 /* This works better than ioctl(...FIONBIO...) on Linux (it causes
846 * connect to return EINPROGRESS, but the ioctl doesn't seem to)
848 if(command==FIONBIO) {
849 ret=fcntl(socket_private_handle->fd, F_GETFL, 0);
851 if(*(gboolean *)arg) {
856 ret=fcntl(socket_private_handle->fd, F_SETFL, ret);
859 #endif /* O_NONBLOCK */
861 ret=ioctl(socket_private_handle->fd, command, arg);
866 g_message(G_GNUC_PRETTY_FUNCTION ": ioctl error: %s",
870 errnum = errno_to_WSA (errnum, G_GNUC_PRETTY_FUNCTION);
871 WSASetLastError (errnum);
873 return(SOCKET_ERROR);
879 int _wapi_select(int nfds G_GNUC_UNUSED, fd_set *readfds, fd_set *writefds,
880 fd_set *exceptfds, struct timeval *timeout)
884 if(startup_count==0) {
885 WSASetLastError(WSANOTINITIALISED);
886 return(SOCKET_ERROR);
889 ret=select(getdtablesize(), readfds, writefds, exceptfds, timeout);
893 g_message(G_GNUC_PRETTY_FUNCTION ": select error: %s",
896 errnum = errno_to_WSA (errnum, G_GNUC_PRETTY_FUNCTION);
897 WSASetLastError (errnum);
899 return(SOCKET_ERROR);
905 void _wapi_FD_CLR(guint32 handle, fd_set *set)
907 struct _WapiHandlePrivate_socket *socket_private_handle;
910 ok=_wapi_lookup_handle (GUINT_TO_POINTER (handle), WAPI_HANDLE_SOCKET,
911 NULL, (gpointer *)&socket_private_handle);
913 g_warning (G_GNUC_PRETTY_FUNCTION
914 ": error looking up socket handle 0x%x", handle);
915 WSASetLastError(WSAENOTSOCK);
919 FD_CLR(socket_private_handle->fd, set);
922 int _wapi_FD_ISSET(guint32 handle, fd_set *set)
924 struct _WapiHandlePrivate_socket *socket_private_handle;
927 ok=_wapi_lookup_handle (GUINT_TO_POINTER (handle), WAPI_HANDLE_SOCKET,
928 NULL, (gpointer *)&socket_private_handle);
930 g_warning (G_GNUC_PRETTY_FUNCTION
931 ": error looking up socket handle 0x%x", handle);
932 WSASetLastError(WSAENOTSOCK);
936 return(FD_ISSET(socket_private_handle->fd, set));
939 void _wapi_FD_SET(guint32 handle, fd_set *set)
941 struct _WapiHandlePrivate_socket *socket_private_handle;
944 ok=_wapi_lookup_handle (GUINT_TO_POINTER (handle), WAPI_HANDLE_SOCKET,
945 NULL, (gpointer *)&socket_private_handle);
947 g_warning (G_GNUC_PRETTY_FUNCTION
948 ": error looking up socket handle 0x%x", handle);
949 WSASetLastError(WSAENOTSOCK);
953 FD_SET(socket_private_handle->fd, set);