1 /* buf trp (transport) - buffered transport using the TCP one */
3 /* Copyright (c) 2004, 2005, 2006, 2007, 2009, 2010. The SimGrid Team.
4 * All rights reserved. */
6 /* This program is free software; you can redistribute it and/or modify it
7 * under the terms of the license (GNU LGPL) which comes with this package. */
10 #include <string.h> /* memset */
14 #include "xbt/sysdep.h"
16 #include "gras/Transport/transport_private.h"
17 #include "gras/Msg/msg_interface.h" /* listener_close_socket */
19 /* FIXME maybe READV is sometime a good thing? */
27 #define MIN(a,b) ((a)<(b)?(a):(b))
30 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(gras_trp_tcp, gras_trp,
31 "TCP buffered transport");
34 *** Specific socket part
38 int port; /* port on this side */
39 int peer_port; /* port on the other side */
40 char *peer_name; /* hostname of the other side */
41 char *peer_proc; /* process on the other side */
42 } s_gras_trp_tcp_sock_data_t, *gras_trp_tcp_sock_data_t;
44 typedef enum { buffering_buf, buffering_iov } buffering_kind;
49 int pos; /* for receive; not exchanged over the net */
53 struct gras_trp_bufdata_ {
55 gras_trp_buf_t in_buf;
56 gras_trp_buf_t out_buf;
60 xbt_dynar_t out_buf_v;
68 /*****************************/
69 /****[ SOCKET MANAGEMENT ]****/
70 /*****************************/
71 /* we exchange port number on client side on socket creation,
72 so we need to be able to talk right now. */
73 static XBT_INLINE void gras_trp_tcp_send(gras_socket_t sock,
75 unsigned long int size);
76 static int gras_trp_tcp_recv(gras_socket_t sock, char *data,
77 unsigned long int size);
80 static int _gras_tcp_proto_number(void);
83 void gras_trp_sock_socket_client(gras_trp_plugin_t ignored,
86 /*OUT*/gras_socket_t sock)
88 gras_trp_tcp_sock_data_t sockdata = xbt_new(s_gras_trp_tcp_sock_data_t,1);
89 sockdata->port = port;
90 sockdata->peer_proc = NULL;
91 sockdata->peer_port = port;
92 sockdata->peer_name = (char *) strdup(host ? host : "localhost");
93 sock->data = sockdata;
95 struct sockaddr_in addr;
97 struct in_addr *haddr;
98 int size = sock->buf_size;
99 uint32_t myport = htonl(((gras_trp_procdata_t)
101 (gras_trp_libdata_id))->myport);
103 sock->incoming = 1; /* TCP sockets are duplex'ed */
105 sock->sd = socket(AF_INET, SOCK_STREAM, 0);
108 THROW1(system_error, 0, "Failed to create socket: %s",
109 sock_errstr(sock_errno));
113 (sock->sd, SOL_SOCKET, SO_RCVBUF, (char *) &size, sizeof(size))
114 || setsockopt(sock->sd, SOL_SOCKET, SO_SNDBUF, (char *) &size,
116 VERB1("setsockopt failed, cannot set buffer size: %s",
117 sock_errstr(sock_errno));
120 he = gethostbyname(sockdata->peer_name);
122 THROW2(system_error, 0, "Failed to lookup hostname %s: %s",
123 sockdata->peer_name, sock_errstr(sock_errno));
126 haddr = ((struct in_addr *) (he->h_addr_list)[0]);
128 memset(&addr, 0, sizeof(struct sockaddr_in));
129 memcpy(&addr.sin_addr, haddr, sizeof(struct in_addr));
130 addr.sin_family = AF_INET;
131 addr.sin_port = htons(sockdata->peer_port);
133 if (connect(sock->sd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
135 THROW3(system_error, 0,
136 "Failed to connect socket to %s:%d (%s)",
137 sockdata->peer_name, sockdata->peer_port, sock_errstr(sock_errno));
140 gras_trp_tcp_send(sock, (char *) &myport, sizeof(uint32_t));
141 DEBUG1("peerport sent to %d", sockdata->peer_port);
143 VERB4("Connect to %s:%d (sd=%d, port %d here)",
144 sockdata->peer_name, sockdata->peer_port, sock->sd, sockdata->port);
148 * gras_trp_sock_socket_server:
150 * Open a socket used to receive messages.
153 void gras_trp_sock_socket_server(gras_trp_plugin_t ignored,
157 int size = sock->buf_size;
159 struct sockaddr_in server;
161 gras_trp_tcp_sock_data_t sockdata = xbt_new(s_gras_trp_tcp_sock_data_t,1);
162 sockdata->port = port;
163 sockdata->peer_port = -1;
164 sockdata->peer_name = NULL;
165 sockdata->peer_proc = NULL;
168 sock->outgoing = 1; /* TCP => duplex mode */
170 server.sin_port = htons((u_short) sockdata->port);
171 server.sin_addr.s_addr = INADDR_ANY;
172 server.sin_family = AF_INET;
173 if ((sock->sd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
174 THROW1(system_error, 0, "Socket allocation failed: %s",
175 sock_errstr(sock_errno));
178 (sock->sd, SOL_SOCKET, SO_REUSEADDR, (char *) &on, sizeof(on)))
179 THROW1(system_error, 0,
180 "setsockopt failed, cannot condition the socket: %s",
181 sock_errstr(sock_errno));
183 if (setsockopt(sock->sd, SOL_SOCKET, SO_RCVBUF,
184 (char *) &size, sizeof(size))
185 || setsockopt(sock->sd, SOL_SOCKET, SO_SNDBUF,
186 (char *) &size, sizeof(size))) {
187 VERB1("setsockopt failed, cannot set buffer size: %s",
188 sock_errstr(sock_errno));
191 if (bind(sock->sd, (struct sockaddr *) &server, sizeof(server)) == -1) {
193 THROW2(system_error, 0,
194 "Cannot bind to port %d: %s", sockdata->port,
195 sock_errstr(sock_errno));
198 DEBUG2("Listen on port %d (sd=%d)", sockdata->port, sock->sd);
199 if (listen(sock->sd, 5) < 0) {
201 THROW2(system_error, 0,
202 "Cannot listen on port %d: %s",
203 sockdata->port, sock_errstr(sock_errno));
206 VERB2("Openned a server socket on port %d (sd=%d)", sockdata->port,
210 static gras_socket_t gras_trp_sock_socket_accept(gras_socket_t sock)
214 struct sockaddr_in peer_in;
215 socklen_t peer_in_len = sizeof(peer_in);
222 socklen_t s = sizeof(int);
227 gras_trp_socket_new(1, &res);
229 sd = accept(sock->sd, (struct sockaddr *) &peer_in, &peer_in_len);
230 tmp_errno = sock_errno;
233 gras_socket_close(sock);
234 THROW1(system_error, 0,
235 "Accept failed (%s). Droping server socket.",
236 sock_errstr(tmp_errno));
239 if (setsockopt(sd, SOL_SOCKET, SO_KEEPALIVE, (char *) &i, s)
240 || setsockopt(sd, _gras_tcp_proto_number(), TCP_NODELAY, (char *) &i,
242 THROW1(system_error, 0,
243 "setsockopt failed, cannot condition the socket: %s",
244 sock_errstr(tmp_errno));
246 res->buf_size = sock->buf_size;
247 size = sock->buf_size;
248 if (setsockopt(sd, SOL_SOCKET, SO_RCVBUF, (char *) &size, sizeof(size))
249 || setsockopt(sd, SOL_SOCKET, SO_SNDBUF, (char *) &size,
251 VERB1("setsockopt failed, cannot set buffer size: %s",
252 sock_errstr(tmp_errno));
254 res->plugin = sock->plugin;
255 res->incoming = sock->incoming;
256 res->outgoing = sock->outgoing;
259 gras_trp_tcp_sock_data_t sockdata = xbt_new(s_gras_trp_tcp_sock_data_t,1);
264 gras_trp_tcp_recv(res, (char *) &hisport, sizeof(hisport));
265 sockdata->peer_port = ntohl(hisport);
266 DEBUG1("peerport %d received", sockdata->peer_port);
268 /* FIXME: Lock to protect inet_ntoa */
269 if (((struct sockaddr *) &peer_in)->sa_family != AF_INET) {
270 sockdata->peer_name = (char *) strdup("unknown");
272 struct in_addr addrAsInAddr;
275 addrAsInAddr.s_addr = peer_in.sin_addr.s_addr;
277 tmp = inet_ntoa(addrAsInAddr);
279 sockdata->peer_name = (char *) strdup(tmp);
281 sockdata->peer_name = (char *) strdup("unknown");
285 VERB3("Accepted from %s:%d (sd=%d)", sockdata->peer_name, sockdata->peer_port, sd);
286 xbt_dynar_push(((gras_trp_procdata_t)
287 gras_libdata_by_id(gras_trp_libdata_id))->sockets, &res);
293 static void gras_trp_sock_socket_close(gras_socket_t sock)
297 return; /* close only once */
299 if (((gras_trp_tcp_sock_data_t)sock->data)->peer_name)
300 free(((gras_trp_tcp_sock_data_t)sock->data)->peer_name);
303 VERB1("close tcp connection %d", sock->sd);
305 /* ask the listener to close the socket */
306 gras_msg_listener_close_socket(sock->sd);
309 /************************************/
310 /****[ end of SOCKET MANAGEMENT ]****/
311 /************************************/
314 /************************************/
315 /****[ UNBUFFERED DATA EXCHANGE ]****/
316 /************************************/
317 /* Temptation to merge this with file data exchange is great,
318 but doesn't work on BillWare (see tcp_write() in portable.h) */
319 static XBT_INLINE void gras_trp_tcp_send(gras_socket_t sock,
321 unsigned long int size)
327 status = tcp_write(sock->sd, data, (size_t) size);
328 DEBUG3("write(%d, %p, %ld);", sock->sd, data, size);
332 if (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK)
334 if (errno == EINTR || errno == EAGAIN)
338 THROW4(system_error, 0, "write(%d,%p,%ld) failed: %s",
339 sock->sd, data, size, sock_errstr(sock_errno));
346 THROW1(system_error, 0, "file descriptor closed (%s)",
347 sock_errstr(sock_errno));
352 static XBT_INLINE int
353 gras_trp_tcp_recv_withbuffer(gras_socket_t sock,
355 unsigned long int size,
356 unsigned long int bufsize)
362 data[0] = sock->recvd_val;
371 DEBUG5("read(%d, %p, %ld) got %d so far (%s)",
372 sock->sd, data + got, bufsize, got,
373 hexa_str((unsigned char *) data, got, 0));
374 status = tcp_read(sock->sd, data + got, (size_t) bufsize);
377 THROW7(system_error, 0,
378 "read(%d,%p,%d) from %s:%d failed: %s; got %d so far",
379 sock->sd, data + got, (int) size, gras_socket_peer_name(sock),
380 gras_socket_peer_port(sock), sock_errstr(sock_errno), got);
382 DEBUG2("Got %d more bytes (%s)", status,
383 hexa_str((unsigned char *) data + got, status, 0));
389 THROW1(system_error, errno,
390 "Socket closed by remote side (got %d bytes before this)",
398 static int gras_trp_tcp_recv(gras_socket_t sock,
399 char *data, unsigned long int size)
401 return gras_trp_tcp_recv_withbuffer(sock, data, size, size);
405 /*******************************************/
406 /****[ end of UNBUFFERED DATA EXCHANGE ]****/
407 /*******************************************/
409 /**********************************/
410 /****[ BUFFERED DATA EXCHANGE ]****/
411 /**********************************/
413 /* Make sure the data is sent */
414 static void gras_trp_bufiov_flush(gras_socket_t sock)
420 gras_trp_bufdata_t *data = sock->bufdata;
424 if (data->out == buffering_buf) {
425 if (XBT_LOG_ISENABLED(gras_trp_tcp, xbt_log_priority_debug))
426 hexa_print("chunk to send ",
427 (unsigned char *) data->out_buf.data, data->out_buf.size);
428 if ((data->out_buf.size - data->out_buf.pos) != 0) {
429 DEBUG3("Send the chunk (size=%d) to %s:%d", data->out_buf.size,
430 gras_socket_peer_name(sock), gras_socket_peer_port(sock));
431 gras_trp_tcp_send(sock, data->out_buf.data, data->out_buf.size);
432 VERB1("Chunk sent (size=%d)", data->out_buf.size);
433 data->out_buf.size = 0;
437 if (data->out == buffering_iov) {
438 DEBUG0("Flush out iov");
439 vect = sock->bufdata->out_buf_v;
440 if ((size = xbt_dynar_length(vect))) {
441 DEBUG1("Flush %d chunks out of this socket", size);
442 writev(sock->sd, xbt_dynar_get_ptr(vect, 0), size);
443 xbt_dynar_reset(vect);
445 data->out_buf.size = 0; /* reset the buffer containing non-stable data */
448 if (data->in == buffering_iov) {
449 DEBUG0("Flush in iov");
450 vect = sock->bufdata->in_buf_v;
451 if ((size = xbt_dynar_length(vect))) {
452 DEBUG1("Get %d chunks from of this socket", size);
453 readv(sock->sd, xbt_dynar_get_ptr(vect, 0), size);
454 xbt_dynar_reset(vect);
461 gras_trp_buf_send(gras_socket_t sock,
463 unsigned long int size, int stable_ignored)
466 gras_trp_bufdata_t *data = (gras_trp_bufdata_t *) sock->bufdata;
471 while (chunk_pos < size) {
472 /* size of the chunk to receive in that shot */
474 min(size - chunk_pos, data->buffsize - data->out_buf.size);
475 DEBUG4("Set the chars %d..%ld into the buffer; size=%ld, ctn=(%s)",
476 (int) data->out_buf.size,
477 ((int) data->out_buf.size) + thissize - 1, size,
478 hexa_str((unsigned char *) chunk, thissize, 0));
480 memcpy(data->out_buf.data + data->out_buf.size, chunk + chunk_pos,
483 data->out_buf.size += thissize;
484 chunk_pos += thissize;
485 DEBUG4("New pos = %d; Still to send = %ld of %ld; ctn sofar=(%s)",
486 data->out_buf.size, size - chunk_pos, size,
487 hexa_str((unsigned char *) chunk, chunk_pos, 0));
489 if (data->out_buf.size == data->buffsize) /* out of space. Flush it */
490 gras_trp_bufiov_flush(sock);
497 gras_trp_buf_recv(gras_socket_t sock, char *chunk, unsigned long int size)
500 gras_trp_bufdata_t *data = sock->bufdata;
501 long int chunk_pos = 0;
505 while (chunk_pos < size) {
506 /* size of the chunk to receive in that shot */
509 if (data->in_buf.size == data->in_buf.pos) { /* out of data. Get more */
511 DEBUG2("Get more data (size=%d,bufsize=%d)",
512 (int) MIN(size - chunk_pos, data->buffsize),
513 (int) data->buffsize);
517 gras_trp_tcp_recv_withbuffer(sock, data->in_buf.data,
518 MIN(size - chunk_pos,
522 data->in_buf.pos = 0;
525 thissize = min(size - chunk_pos, data->in_buf.size - data->in_buf.pos);
526 memcpy(chunk + chunk_pos, data->in_buf.data + data->in_buf.pos,
529 data->in_buf.pos += thissize;
530 chunk_pos += thissize;
531 DEBUG4("New pos = %d; Still to receive = %ld of %ld. Ctn so far=(%s)",
532 data->in_buf.pos, size - chunk_pos, size,
533 hexa_str((unsigned char *) chunk, chunk_pos, 0));
535 /* indicate on need to the gras_select function that there is more to read on this socket so that it does not actually select */
536 sock->moredata = (data->in_buf.size > data->in_buf.pos);
537 DEBUG1("There is %smore data", (sock->moredata ? "" : "no "));
543 /*****************************************/
544 /****[ end of BUFFERED DATA EXCHANGE ]****/
545 /*****************************************/
547 /********************************/
548 /****[ VECTOR DATA EXCHANGE ]****/
549 /********************************/
552 gras_trp_iov_send(gras_socket_t sock,
553 const char *chunk, unsigned long int size, int stable)
556 gras_trp_bufdata_t *data = (gras_trp_bufdata_t *) sock->bufdata;
559 DEBUG1("Buffer one chunk to be sent later (%s)",
560 hexa_str((char *) chunk, size, 0));
562 elm.iov_len = (size_t) size;
565 /* data storage won't last until flush. Save it in a buffer if we can */
567 if (size > data->buffsize - data->out_buf.size) {
569 flush the socket, using data in its actual storage */
570 elm.iov_base = (void *) chunk;
571 xbt_dynar_push(data->out_buf_v, &elm);
573 gras_trp_bufiov_flush(sock);
576 /* buffer big enough:
577 copy data into it, and chain it for upcoming writev */
578 memcpy(data->out_buf.data + data->out_buf.size, chunk, size);
579 elm.iov_base = (void *) (data->out_buf.data + data->out_buf.size);
580 data->out_buf.size += size;
582 xbt_dynar_push(data->out_buf_v, &elm);
586 /* data storage stable. Chain it */
588 elm.iov_base = (void *) chunk;
589 xbt_dynar_push(data->out_buf_v, &elm);
594 gras_trp_iov_recv(gras_socket_t sock, char *chunk, unsigned long int size)
598 DEBUG0("Buffer one chunk to be received later");
599 elm.iov_base = (void *) chunk;
600 elm.iov_len = (size_t) size;
601 xbt_dynar_push(sock->bufdata->in_buf_v, &elm);
607 /***************************************/
608 /****[ end of VECTOR DATA EXCHANGE ]****/
609 /***************************************/
613 *** Prototypes of BUFFERED
616 void gras_trp_buf_socket_client(gras_trp_plugin_t self,
620 void gras_trp_buf_socket_server(gras_trp_plugin_t self,
623 gras_socket_t gras_trp_buf_socket_accept(gras_socket_t sock);
625 void gras_trp_buf_socket_close(gras_socket_t sd);
628 gras_socket_t gras_trp_buf_init_sock(gras_socket_t sock)
630 gras_trp_bufdata_t *data = xbt_new(gras_trp_bufdata_t, 1);
632 data->buffsize = 100 * 1024; /* 100k */
634 data->in_buf.size = 0;
635 data->in_buf.data = xbt_malloc(data->buffsize);
636 data->in_buf.pos = 0; /* useless, indeed, since size==pos */
638 data->out_buf.size = 0;
639 data->out_buf.data = xbt_malloc(data->buffsize);
640 data->out_buf.pos = data->out_buf.size;
643 data->in_buf_v = data->out_buf_v = NULL;
644 data->in_buf_v = xbt_dynar_new(sizeof(struct iovec), NULL);
645 data->out_buf_v = xbt_dynar_new(sizeof(struct iovec), NULL);
646 data->out = buffering_iov;
648 data->out = buffering_buf;
651 data->in = buffering_buf;
653 sock->bufdata = data;
658 *** Info about who's speaking
660 static int gras_trp_tcp_my_port(gras_socket_t s) {
661 gras_trp_tcp_sock_data_t sockdata = s->data;
662 return sockdata->port;
664 static int gras_trp_tcp_peer_port(gras_socket_t s) {
665 gras_trp_tcp_sock_data_t sockdata = s->data;
666 return sockdata->peer_port;
668 static const char* gras_trp_tcp_peer_name(gras_socket_t s) {
669 gras_trp_tcp_sock_data_t sockdata = s->data;
670 return sockdata->peer_name;
672 static const char* gras_trp_tcp_peer_proc(gras_socket_t s) {
673 gras_trp_tcp_sock_data_t sockdata = s->data;
674 return sockdata->peer_proc;
676 static void gras_trp_tcp_peer_proc_set(gras_socket_t s,char *name) {
677 gras_trp_tcp_sock_data_t sockdata = s->data;
678 sockdata->peer_proc = xbt_strdup(name);
684 void gras_trp_tcp_setup(gras_trp_plugin_t plug)
687 plug->my_port = gras_trp_tcp_my_port;
688 plug->peer_port = gras_trp_tcp_peer_port;
689 plug->peer_name = gras_trp_tcp_peer_name;
690 plug->peer_proc = gras_trp_tcp_peer_proc;
691 plug->peer_proc_set = gras_trp_tcp_peer_proc_set;
694 plug->socket_client = gras_trp_buf_socket_client;
695 plug->socket_server = gras_trp_buf_socket_server;
696 plug->socket_accept = gras_trp_buf_socket_accept;
697 plug->socket_close = gras_trp_buf_socket_close;
700 plug->send = gras_trp_iov_send;
702 plug->send = gras_trp_buf_send;
704 plug->recv = gras_trp_buf_recv;
706 plug->raw_send = gras_trp_tcp_send;
707 plug->raw_recv = gras_trp_tcp_recv;
709 plug->flush = gras_trp_bufiov_flush;
715 void gras_trp_buf_socket_client(gras_trp_plugin_t self,
718 /* OUT */ gras_socket_t sock)
721 gras_trp_sock_socket_client(NULL, host,port,sock);
722 gras_trp_buf_init_sock(sock);
726 * gras_trp_buf_socket_server:
728 * Open a socket used to receive messages.
730 void gras_trp_buf_socket_server(gras_trp_plugin_t self,
732 /* OUT */ gras_socket_t sock)
735 gras_trp_sock_socket_server(NULL, port, sock);
736 gras_trp_buf_init_sock(sock);
739 gras_socket_t gras_trp_buf_socket_accept(gras_socket_t sock)
741 return gras_trp_buf_init_sock(gras_trp_sock_socket_accept(sock));
744 void gras_trp_buf_socket_close(gras_socket_t sock)
746 gras_trp_bufdata_t *data = sock->bufdata;
748 if (data->in_buf.size != data->in_buf.pos) {
749 WARN3("Socket closed, but %d bytes were unread (size=%d,pos=%d)",
750 data->in_buf.size - data->in_buf.pos,
751 data->in_buf.size, data->in_buf.pos);
753 if (data->in_buf.data)
754 free(data->in_buf.data);
756 if (data->out_buf.size != data->out_buf.pos) {
757 DEBUG2("Flush the socket before closing (in=%d,out=%d)",
758 data->in_buf.size, data->out_buf.size);
759 gras_trp_bufiov_flush(sock);
761 if (data->out_buf.data)
762 free(data->out_buf.data);
765 if (data->in_buf_v) {
766 if (xbt_dynar_length(data->in_buf_v))
767 WARN0("Socket closed, but some bytes were unread");
768 xbt_dynar_free(&data->in_buf_v);
770 if (data->out_buf_v) {
771 if (xbt_dynar_length(data->out_buf_v)) {
772 DEBUG0("Flush the socket before closing");
773 gras_trp_bufiov_flush(sock);
775 xbt_dynar_free(&data->out_buf_v);
780 gras_trp_sock_socket_close(sock);
783 /****************************/
784 /****[ HELPER FUNCTIONS ]****/
785 /****************************/
788 * Returns the tcp protocol number from the network protocol data base.
790 * getprotobyname() is not thread safe. We need to lock it.
792 static int _gras_tcp_proto_number(void)
794 struct protoent *fetchedEntry;
795 static int returnValue = 0;
797 if (returnValue == 0) {
798 fetchedEntry = getprotobyname("tcp");
799 xbt_assert0(fetchedEntry, "getprotobyname(tcp) gave NULL");
800 returnValue = fetchedEntry->p_proto;
806 #ifdef HAVE_WINSOCK_H
807 #define RETSTR( x ) case x: return #x
809 const char *gras_wsa_err2string(int err)
818 RETSTR(WSAEWOULDBLOCK);
819 RETSTR(WSAEINPROGRESS);
822 RETSTR(WSAEDESTADDRREQ);
824 RETSTR(WSAEPROTOTYPE);
825 RETSTR(WSAENOPROTOOPT);
826 RETSTR(WSAEPROTONOSUPPORT);
827 RETSTR(WSAESOCKTNOSUPPORT);
828 RETSTR(WSAEOPNOTSUPP);
829 RETSTR(WSAEPFNOSUPPORT);
830 RETSTR(WSAEAFNOSUPPORT);
831 RETSTR(WSAEADDRINUSE);
832 RETSTR(WSAEADDRNOTAVAIL);
834 RETSTR(WSAENETUNREACH);
835 RETSTR(WSAENETRESET);
836 RETSTR(WSAECONNABORTED);
837 RETSTR(WSAECONNRESET);
841 RETSTR(WSAESHUTDOWN);
842 RETSTR(WSAETOOMANYREFS);
843 RETSTR(WSAETIMEDOUT);
844 RETSTR(WSAECONNREFUSED);
846 RETSTR(WSAENAMETOOLONG);
847 RETSTR(WSAEHOSTDOWN);
848 RETSTR(WSAEHOSTUNREACH);
849 RETSTR(WSAENOTEMPTY);
855 RETSTR(WSASYSNOTREADY);
856 RETSTR(WSAVERNOTSUPPORTED);
857 RETSTR(WSANOTINITIALISED);
862 RETSTR(WSAECANCELLED);
863 RETSTR(WSAEINVALIDPROCTABLE);
864 RETSTR(WSAEINVALIDPROVIDER);
865 RETSTR(WSASYSCALLFAILURE);
866 RETSTR(WSASERVICE_NOT_FOUND);
867 RETSTR(WSATYPE_NOT_FOUND);
868 RETSTR(WSA_E_NO_MORE);
869 RETSTR(WSA_E_CANCELLED);
871 #endif /* HAVE_WINSOCK2 */
873 RETSTR(WSAHOST_NOT_FOUND);
874 RETSTR(WSATRY_AGAIN);
875 RETSTR(WSANO_RECOVERY);
878 return "unknown WSA error";
880 #endif /* HAVE_WINSOCK_H */
882 /***********************************/
883 /****[ end of HELPER FUNCTIONS ]****/
884 /***********************************/