2 This file is part of GNUnet.
3 (C) 2009 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 2, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file util/network.c
23 * @brief basic, low-level networking interface
28 #include "gnunet_disk_lib.h"
30 #include "gnunet_container_lib.h"
32 #define DEBUG_NETWORK GNUNET_NO
34 #ifndef INVALID_SOCKET
35 #define INVALID_SOCKET -1
39 struct GNUNET_NETWORK_Handle
45 struct GNUNET_NETWORK_FDSet
49 * Maximum number of any socket socket descriptor in the set
54 * Bitset with the descriptors.
60 * Linked list of handles
62 struct GNUNET_CONTAINER_SList *handles;
68 #define FD_COPY(s, d) (memcpy ((d), (s), sizeof (fd_set)))
73 * Set if a socket should use blocking or non-blocking IO.
75 * @param doBlock blocking mode
76 * @return GNUNET_OK on success, GNUNET_SYSERR on error
79 socket_set_blocking (struct GNUNET_NETWORK_Handle *fd, int doBlock)
85 if (ioctlsocket (fd->fd, FIONBIO, &mode) == SOCKET_ERROR)
88 SetErrnoFromWinsockError (WSAGetLastError ());
89 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "ioctlsocket");
96 int flags = fcntl (fd->fd, F_GETFL);
100 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "fcntl");
101 return GNUNET_SYSERR;
104 flags &= ~O_NONBLOCK;
108 if (0 != fcntl (fd->fd, F_SETFL, flags))
111 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "fcntl");
112 return GNUNET_SYSERR;
121 * Make a socket non-inheritable to child processes
123 * @param h the socket to make non-inheritable
124 * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
125 * @warning Not implemented on Windows
128 socket_set_inheritable (const struct GNUNET_NETWORK_Handle *h)
131 i = fcntl (h->fd, F_GETFD);
132 if (i == (i | FD_CLOEXEC))
134 return (fcntl (h->fd, F_SETFD, i | FD_CLOEXEC) == 0)
135 ? GNUNET_OK : GNUNET_SYSERR;
142 * The MSG_NOSIGNAL equivalent on Mac OS X
144 * @param h the socket to make non-delaying
147 socket_set_nosigpipe (const struct GNUNET_NETWORK_Handle *h)
151 setsockopt (h->fd, SOL_SOCKET, SO_NOSIGPIPE, &value, sizeof (value)))
152 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "setsockopt");
158 * Disable delays when sending data via the socket.
159 * (GNUnet makes sure that messages are as big as
162 * @param h the socket to make non-delaying
165 socket_set_nodelay (const struct GNUNET_NETWORK_Handle *h)
169 setsockopt (h->fd, IPPROTO_TCP, TCP_NODELAY, &value, sizeof (value)))
170 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "setsockopt");
175 * accept a new connection on a socket
177 * @param desc bound socket
178 * @param address address of the connecting peer, may be NULL
179 * @param address_len length of address
180 * @return client socket
182 struct GNUNET_NETWORK_Handle *
183 GNUNET_NETWORK_socket_accept (const struct GNUNET_NETWORK_Handle *desc,
184 struct sockaddr *address,
185 socklen_t * address_len)
187 struct GNUNET_NETWORK_Handle *ret;
188 ret = GNUNET_malloc (sizeof (struct GNUNET_NETWORK_Handle));
189 ret->fd = accept (desc->fd, address, address_len);
190 if (ret->fd == INVALID_SOCKET)
193 SetErrnoFromWinsockError (WSAGetLastError ());
199 if (ret->fd >= FD_SETSIZE)
201 GNUNET_break (0 == close (ret->fd));
207 if (GNUNET_SYSERR == socket_set_blocking (ret, GNUNET_NO))
211 /* we might want to treat this one as fatal... */
213 GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (ret));
218 if (GNUNET_OK != socket_set_inheritable (ret))
219 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
220 "socket_set_inheritable");
223 socket_set_nosigpipe (ret);
225 socket_set_nodelay (ret);
231 * Bind to a connected socket
233 * @param address address to be bound
234 * @param address_len length of address
235 * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
238 GNUNET_NETWORK_socket_bind (struct GNUNET_NETWORK_Handle *desc,
239 const struct sockaddr *address,
240 socklen_t address_len)
244 ret = bind (desc->fd, address, address_len);
246 if (SOCKET_ERROR == ret)
247 SetErrnoFromWinsockError (WSAGetLastError ());
249 return ret == 0 ? GNUNET_OK : GNUNET_SYSERR;
256 * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
259 GNUNET_NETWORK_socket_close (struct GNUNET_NETWORK_Handle *desc)
265 ret = closesocket (desc->fd);
266 SetErrnoFromWinsockError (WSAGetLastError ());
268 ret = close (desc->fd);
273 return (ret == 0) ? GNUNET_OK : GNUNET_SYSERR;
280 * @param address peer address
281 * @param address_len length of address
282 * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
285 GNUNET_NETWORK_socket_connect (const struct GNUNET_NETWORK_Handle *desc,
286 const struct sockaddr *address,
287 socklen_t address_len)
290 ret = connect (desc->fd, address, address_len);
293 if (SOCKET_ERROR == ret)
296 SetErrnoFromWinsockError (WSAGetLastError ());
297 if (errno == EWOULDBLOCK)
301 return ret == 0 ? GNUNET_OK : GNUNET_SYSERR;
309 * @param level protocol level of the option
310 * @param optname identifier of the option
311 * @param optval options
312 * @param optlen length of optval
313 * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
316 GNUNET_NETWORK_socket_getsockopt (const struct GNUNET_NETWORK_Handle *desc,
317 int level, int optname, void *optval,
321 ret = getsockopt (desc->fd, level, optname, optval, optlen);
324 if (ret == 0 && level == SOL_SOCKET && optname == SO_ERROR)
325 *((int *) optval) = GetErrnoFromWinsockError (*((int *) optval));
327 else if (SOCKET_ERROR == ret)
328 SetErrnoFromWinsockError (WSAGetLastError ());
331 return ret == 0 ? GNUNET_OK : GNUNET_SYSERR;
338 * @param backlog length of the listen queue
339 * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
342 GNUNET_NETWORK_socket_listen (const struct GNUNET_NETWORK_Handle *desc,
346 ret = listen (desc->fd, backlog);
349 if (SOCKET_ERROR == ret)
350 SetErrnoFromWinsockError (WSAGetLastError ());
353 return ret == 0 ? GNUNET_OK : GNUNET_SYSERR;
358 * How much data is available to be read on this descriptor?
360 * Returns GNUNET_NO if no data is available, or on error!
364 GNUNET_NETWORK_socket_recvfrom_amount (const struct GNUNET_NETWORK_Handle
368 unsigned int pending;
370 /* How much is there to be read? */
371 error = ioctl (desc->fd, FIONREAD, &pending);
380 * Read data from a connected socket (always non-blocking).
382 * @param buffer buffer
383 * @param length length of buffer
384 * @param src_addr either the source to recv from, or all zeroes
385 * to be filled in by recvfrom
386 * @param addrlen length of the addr
389 GNUNET_NETWORK_socket_recvfrom (const struct GNUNET_NETWORK_Handle * desc,
390 void *buffer, size_t length,
391 struct sockaddr * src_addr,
399 flags |= MSG_DONTWAIT;
402 ret = recvfrom (desc->fd, buffer, length, flags, src_addr, addrlen);
405 if (SOCKET_ERROR == ret)
406 SetErrnoFromWinsockError (WSAGetLastError ());
414 * Read data from a connected socket (always non-blocking).
416 * @param buffer buffer
417 * @param length length of buffer
420 GNUNET_NETWORK_socket_recv (const struct GNUNET_NETWORK_Handle * desc,
421 void *buffer, size_t length)
428 flags |= MSG_DONTWAIT;
431 ret = recv (desc->fd, buffer, length, flags);
434 if (SOCKET_ERROR == ret)
435 SetErrnoFromWinsockError (WSAGetLastError ());
443 * Send data (always non-blocking).
446 * @param buffer data to send
447 * @param length size of the buffer
448 * @return number of bytes sent, GNUNET_SYSERR on error
451 GNUNET_NETWORK_socket_send (const struct GNUNET_NETWORK_Handle * desc,
452 const void *buffer, size_t length)
459 flags |= MSG_DONTWAIT;
463 flags |= MSG_NOSIGNAL;
466 ret = send (desc->fd, buffer, length, flags);
469 if (SOCKET_ERROR == ret)
470 SetErrnoFromWinsockError (WSAGetLastError ());
478 * Send data to a particular destination (always non-blocking).
479 * This function only works for UDP sockets.
482 * @param message data to send
483 * @param length size of the data
484 * @param dest_addr destination address
485 * @param dest_len length of address
486 * @return number of bytes sent, GNUNET_SYSERR on error
489 GNUNET_NETWORK_socket_sendto (const struct GNUNET_NETWORK_Handle * desc,
490 const void *message, size_t length,
491 const struct sockaddr * dest_addr,
499 flags |= MSG_DONTWAIT;
502 flags |= MSG_NOSIGNAL;
504 ret = sendto (desc->fd, message, length, flags, dest_addr, dest_len);
506 if (SOCKET_ERROR == ret)
507 SetErrnoFromWinsockError (WSAGetLastError ());
516 * @param level protocol level of the option
517 * @param option_name option identifier
518 * @param option_value value to set
519 * @param option_len size of option_value
520 * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
523 GNUNET_NETWORK_socket_setsockopt (struct GNUNET_NETWORK_Handle *fd,
524 int level, int option_name,
525 const void *option_value,
526 socklen_t option_len)
530 ret = setsockopt (fd->fd, level, option_name, option_value, option_len);
532 if (SOCKET_ERROR == ret)
533 SetErrnoFromWinsockError (WSAGetLastError ());
535 return ret == 0 ? GNUNET_OK : GNUNET_SYSERR;
540 * Create a new socket. Configure it for non-blocking IO and
541 * mark it as non-inheritable to child processes (set the
542 * close-on-exec flag).
544 * @param domain domain of the socket
545 * @param type socket type
546 * @param protocol network protocol
547 * @return new socket, NULL on error
549 struct GNUNET_NETWORK_Handle *
550 GNUNET_NETWORK_socket_create (int domain, int type, int protocol)
552 struct GNUNET_NETWORK_Handle *ret;
553 ret = GNUNET_malloc (sizeof (struct GNUNET_NETWORK_Handle));
554 ret->fd = socket (domain, type, protocol);
555 if (INVALID_SOCKET == ret->fd)
558 SetErrnoFromWinsockError (WSAGetLastError ());
565 if (ret->fd >= FD_SETSIZE)
567 GNUNET_break (0 == close (ret->fd));
574 if (GNUNET_SYSERR == socket_set_blocking (ret, GNUNET_NO))
576 /* we might want to treat this one as fatal... */
578 GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (ret));
583 if (GNUNET_OK != socket_set_inheritable (ret))
584 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
585 "socket_set_inheritable");
588 socket_set_nosigpipe (ret);
590 if (type == SOCK_STREAM)
591 socket_set_nodelay (ret);
597 * Shut down socket operations
599 * @param how type of shutdown
600 * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
603 GNUNET_NETWORK_socket_shutdown (struct GNUNET_NETWORK_Handle *desc, int how)
607 ret = shutdown (desc->fd, how);
610 SetErrnoFromWinsockError (WSAGetLastError ());
612 return ret == 0 ? GNUNET_OK : GNUNET_SYSERR;
621 GNUNET_NETWORK_fdset_zero (struct GNUNET_NETWORK_FDSet *fds)
626 GNUNET_CONTAINER_slist_clear (fds->handles);
631 * Add a socket to the FD set
633 * @param desc socket to add
636 GNUNET_NETWORK_fdset_set (struct GNUNET_NETWORK_FDSet *fds,
637 const struct GNUNET_NETWORK_Handle *desc)
639 FD_SET (desc->fd, &fds->sds);
640 if (desc->fd + 1 > fds->nsds)
641 fds->nsds = desc->fd + 1;
646 * Check whether a socket is part of the fd set
649 * @return 0 if the FD is not set
652 GNUNET_NETWORK_fdset_isset (const struct GNUNET_NETWORK_FDSet *fds,
653 const struct GNUNET_NETWORK_Handle *desc)
655 return FD_ISSET (desc->fd, &fds->sds);
660 * Add one fd set to another
661 * @param dst the fd set to add to
662 * @param src the fd set to add from
665 GNUNET_NETWORK_fdset_add (struct GNUNET_NETWORK_FDSet *dst,
666 const struct GNUNET_NETWORK_FDSet *src)
669 for (nfds = src->nsds; nfds > 0; nfds--)
670 if (FD_ISSET (nfds, &src->sds))
673 FD_SET (nfds, &dst->sds);
674 if (nfds + 1 > dst->nsds)
675 dst->nsds = nfds + 1;
678 GNUNET_CONTAINER_slist_append (dst->handles, src->handles);
684 * Copy one fd set to another
686 * @param to destination
690 GNUNET_NETWORK_fdset_copy (struct GNUNET_NETWORK_FDSet *to,
691 const struct GNUNET_NETWORK_FDSet *from)
693 FD_COPY (&from->sds, &to->sds);
694 to->nsds = from->nsds;
697 GNUNET_CONTAINER_slist_clear (to->handles);
698 GNUNET_CONTAINER_slist_append (to->handles, from->handles);
703 GNUNET_NETWORK_get_fd (struct GNUNET_NETWORK_Handle *desc)
709 * Copy a native fd set
711 * @param to destination
712 * @param from native source set
713 * @param nfds the biggest socket number in from + 1
716 GNUNET_NETWORK_fdset_copy_native (struct GNUNET_NETWORK_FDSet *to,
717 const fd_set * from, int nfds)
719 FD_COPY (from, &to->sds);
724 * Add a file handle to the fd set
726 * @param h the file handle to add
729 GNUNET_NETWORK_fdset_handle_set (struct GNUNET_NETWORK_FDSet *fds,
730 const struct GNUNET_DISK_FileHandle *h)
735 GNUNET_DISK_internal_file_handle_ (h, &hw, sizeof (HANDLE));
736 GNUNET_CONTAINER_slist_add (fds->handles,
737 GNUNET_CONTAINER_SLIST_DISPOSITION_TRANSIENT,
738 &hw, sizeof (HANDLE));
742 GNUNET_DISK_internal_file_handle_ (h, &fd, sizeof (int));
743 FD_SET (fd, &fds->sds);
744 if (fd + 1 > fds->nsds)
752 * Check if a file handle is part of an fd set
754 * @param h file handle
755 * @return GNUNET_YES if the file handle is part of the set
758 GNUNET_NETWORK_fdset_handle_isset (const struct GNUNET_NETWORK_FDSet *fds,
759 const struct GNUNET_DISK_FileHandle *h)
763 return GNUNET_CONTAINER_slist_contains (fds->handles, &h->h,
766 return FD_ISSET (h->fd, &fds->sds);
772 * Checks if two fd sets overlap
773 * @param fds1 first fd set
774 * @param fds2 second fd set
775 * @return GNUNET_YES if they do overlap, GNUNET_NO otherwise
778 GNUNET_NETWORK_fdset_overlap (const struct GNUNET_NETWORK_FDSet *fds1,
779 const struct GNUNET_NETWORK_FDSet *fds2)
783 if (nfds < fds2->nsds)
785 for (; nfds >= 0; nfds--)
786 if (FD_ISSET (nfds, &fds1->sds) && FD_ISSET (nfds, &fds2->sds))
790 struct GNUNET_CONTAINER_SList_Iterator *it;
792 for (it = GNUNET_CONTAINER_slist_begin (fds1->handles);
793 GNUNET_CONTAINER_slist_end (it) != GNUNET_YES;
794 GNUNET_CONTAINER_slist_next (it))
798 h = GNUNET_CONTAINER_slist_get (it, NULL);
799 if (GNUNET_CONTAINER_slist_contains
800 (fds2->handles, h, sizeof (HANDLE)))
802 GNUNET_CONTAINER_slist_iter_destroy (it);
806 GNUNET_CONTAINER_slist_iter_destroy (it);
815 * @return a new fd set
817 struct GNUNET_NETWORK_FDSet *
818 GNUNET_NETWORK_fdset_create ()
820 struct GNUNET_NETWORK_FDSet *fds;
821 fds = GNUNET_malloc (sizeof (struct GNUNET_NETWORK_FDSet));
823 fds->handles = GNUNET_CONTAINER_slist_create ();
825 GNUNET_NETWORK_fdset_zero (fds);
831 * Releases the associated memory of an fd set
835 GNUNET_NETWORK_fdset_destroy (struct GNUNET_NETWORK_FDSet *fds)
838 GNUNET_CONTAINER_slist_destroy (fds->handles);
844 * Check if sockets meet certain conditions
845 * @param rfds set of sockets to be checked for readability
846 * @param wfds set of sockets to be checked for writability
847 * @param efds set of sockets to be checked for exceptions
848 * @param timeout relative value when to return
849 * @return number of selected sockets, GNUNET_SYSERR on error
852 GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
853 struct GNUNET_NETWORK_FDSet *wfds,
854 struct GNUNET_NETWORK_FDSet *efds,
855 const struct GNUNET_TIME_Relative timeout)
869 handles = GNUNET_CONTAINER_slist_count (rfds->handles);
874 nfds = GNUNET_MAX (nfds, wfds->nsds);
876 handles += GNUNET_CONTAINER_slist_count (wfds->handles);
881 nfds = GNUNET_MAX (nfds, efds->nsds);
883 handles += GNUNET_CONTAINER_slist_count (efds->handles);
888 tv.tv_sec = timeout.value / GNUNET_TIME_UNIT_SECONDS.value;
890 1000 * (timeout.value - (tv.tv_sec * GNUNET_TIME_UNIT_SECONDS.value));
891 if ((nfds == 0) && (timeout.value == GNUNET_TIME_UNIT_FOREVER_REL.value)
897 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
899 ("Fatal internal logic error, process hangs in `%s' (abort with CTRL-C)!\n"),
904 return select (nfds + 1,
905 (rfds != NULL) ? &rfds->sds : NULL,
906 (wfds != NULL) ? &wfds->sds : NULL,
907 (efds != NULL) ? &efds->sds : NULL,
908 (timeout.value == GNUNET_TIME_UNIT_FOREVER_REL.value)
913 fd_set sock_read, sock_write, sock_except;
914 fd_set aread, awrite, aexcept;
915 struct GNUNET_CONTAINER_SList *handles_read, *handles_write,
919 struct timeval tvslice;
923 #define SAFE_FD_ISSET(fd, set) (set != NULL && FD_ISSET(fd, set))
925 /* calculate how long we need to wait in milliseconds */
926 if (timeout.value == GNUNET_TIME_UNIT_FOREVER_REL.value)
930 ms_total = timeout.value / GNUNET_TIME_UNIT_MILLISECONDS.value;
932 /* select() may be used as a portable way to sleep */
933 if (!(rfds || wfds || efds))
940 handles_read = GNUNET_CONTAINER_slist_create ();
941 handles_write = GNUNET_CONTAINER_slist_create ();
942 handles_except = GNUNET_CONTAINER_slist_create ();
945 sock_read = rfds->sds;
947 FD_ZERO (&sock_read);
949 sock_write = wfds->sds;
951 FD_ZERO (&sock_write);
953 sock_except = efds->sds;
955 FD_ZERO (&sock_except);
957 /* multiplex between winsock select() and waiting on the handles */
961 limit = GetTickCount () + ms_total;
970 /* overwrite the zero'd sets here; the select call
971 * will clear those that are not active */
972 FD_COPY (&sock_read, &aread);
973 FD_COPY (&sock_write, &awrite);
974 FD_COPY (&sock_except, &aexcept);
976 tvslice.tv_usec = 100000;
978 select (nfds + 1, &aread, &awrite, &aexcept,
979 &tvslice)) == SOCKET_ERROR)
982 SetErrnoFromWinsockError (WSAGetLastError ());
983 if (errno == ENOTSOCK)
987 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "select");
990 goto select_loop_end;
994 /* Poll read pipes */
998 struct GNUNET_CONTAINER_SList_Iterator *i;
999 for (i = GNUNET_CONTAINER_slist_begin (rfds->handles);
1000 GNUNET_CONTAINER_slist_end (i) != GNUNET_YES;
1001 GNUNET_CONTAINER_slist_next (i))
1006 h = *(HANDLE *) GNUNET_CONTAINER_slist_get (i, NULL);
1007 if (!PeekNamedPipe (h, NULL, 0, NULL, &dwBytes, NULL))
1010 SetErrnoFromWinError (GetLastError ());
1013 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR,
1017 goto select_loop_end;
1022 GNUNET_CONTAINER_slist_add (handles_read,
1023 GNUNET_CONTAINER_SLIST_DISPOSITION_TRANSIENT,
1024 &h, sizeof (HANDLE));
1028 GNUNET_CONTAINER_slist_iter_destroy (i);
1031 /* Poll for faulty pipes */
1035 struct GNUNET_CONTAINER_SList_Iterator *i;
1036 for (i = GNUNET_CONTAINER_slist_begin (efds->handles);
1037 GNUNET_CONTAINER_slist_end (i) != GNUNET_YES;
1038 GNUNET_CONTAINER_slist_next (i))
1043 h = *(HANDLE *) GNUNET_CONTAINER_slist_get (i, NULL);
1044 if (!PeekNamedPipe (h, NULL, 0, NULL, &dwBytes, NULL))
1047 GNUNET_CONTAINER_slist_add (handles_except,
1048 GNUNET_CONTAINER_SLIST_DISPOSITION_TRANSIENT,
1049 &h, sizeof (HANDLE));
1053 GNUNET_CONTAINER_slist_iter_destroy (i);
1058 GNUNET_CONTAINER_slist_append (handles_write, wfds->handles);
1059 retcode += GNUNET_CONTAINER_slist_count (wfds->handles);
1062 /* Check for closed sockets */
1063 for (i = 0; i < nfds; i++)
1066 if (SAFE_FD_ISSET (i, &sock_read))
1069 struct sockaddr addr;
1071 if (getpeername (i, &addr, &len) == SOCKET_ERROR)
1077 (i, SOL_SOCKET, SO_ERROR, (char *) &err, &len) == 0
1078 && err == WSAENOTCONN)
1081 if (!SAFE_FD_ISSET (i, &aread))
1092 if (retcode == 0 && nfds == 0)
1093 Sleep (GNUNET_MIN (100, limit - GetTickCount ()));
1095 while (retcode == 0 && (ms_total == INFINITE || GetTickCount () < limit));
1103 GNUNET_NETWORK_fdset_zero (rfds);
1104 GNUNET_NETWORK_fdset_copy_native (rfds, &aread, retcode);
1105 GNUNET_CONTAINER_slist_clear (rfds->handles);
1106 GNUNET_CONTAINER_slist_append (rfds->handles, handles_read);
1112 GNUNET_NETWORK_fdset_zero (wfds);
1113 GNUNET_NETWORK_fdset_copy_native (wfds, &awrite, retcode);
1114 GNUNET_CONTAINER_slist_clear (wfds->handles);
1115 GNUNET_CONTAINER_slist_append (wfds->handles, handles_write);
1120 GNUNET_NETWORK_fdset_zero (efds);
1121 GNUNET_NETWORK_fdset_copy_native (efds, &aexcept, retcode);
1122 GNUNET_CONTAINER_slist_clear (efds->handles);
1123 GNUNET_CONTAINER_slist_append (efds->handles, handles_except);
1127 GNUNET_CONTAINER_slist_destroy (handles_read);
1128 GNUNET_CONTAINER_slist_destroy (handles_write);
1129 GNUNET_CONTAINER_slist_destroy (handles_except);
1136 /* end of network.c */