Overview
Comment: | Check for more socket-related headers / functions. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
896084c3406258123cbdfb56d00606c6 |
User & Date: | js on 2013-05-22 18:42:46 |
Other Links: | manifest | tags |
Context
2013-05-22
| ||
18:45 | Import OFThread.h unconditionally. check-in: d7365be372 user: js tags: trunk | |
18:42 | Check for more socket-related headers / functions. check-in: 896084c340 user: js tags: trunk | |
2013-05-13
| ||
16:46 | Get rid of a strange ObjC++ + Win32 warning. check-in: 482454bc43 user: js tags: trunk | |
Changes
Modified configure.ac from [6ce483001a] to [b23f940e4b].
︙ | ︙ | |||
593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 | ]) AC_CHECK_FUNC(link, [ AC_DEFINE(OF_HAVE_LINK, 1, [Whether we have link()]) ]) AC_CHECK_FUNC(symlink, [ AC_DEFINE(OF_HAVE_SYMLINK, 1, [Whether we have symlink()]) ]) AC_ARG_ENABLE(sockets, AS_HELP_STRING([--disable-sockets], [disable socket support])) AS_IF([test x"$enable_sockets" != x"no"], [ AC_DEFINE(OF_HAVE_SOCKETS, 1, [Whether we have sockets]) AC_SUBST(USE_SRCS_SOCKETS, '${SRCS_SOCKETS}') AC_CHECK_LIB(socket, socket, LIBS="$LIBS -lsocket") AC_CHECK_LIB(network, socket, LIBS="$LIBS -lnetwork") AC_CHECK_LIB(ws2_32, main, LIBS="$LIBS -lws2_32") AC_CHECK_FUNC(kqueue, [ AC_DEFINE(HAVE_KQUEUE, 1, [Whether we have kqueue]) AC_SUBST(OFSTREAMOBSERVER_KQUEUE_M, "OFStreamObserver_kqueue.m") ]) AC_CHECK_HEADER(poll.h, [ AC_DEFINE(HAVE_POLL_H, 1, [Whether we have poll.h]) AC_SUBST(OFSTREAMOBSERVER_POLL_M, "OFStreamObserver_poll.m") ]) AC_CHECK_HEADER(sys/select.h, [ AC_DEFINE(HAVE_SYS_SELECT_H, 1, [Whether we have sys/select.h]) AC_SUBST(OFSTREAMOBSERVER_SELECT_M, "OFStreamObserver_select.m") ]) case "$host_os" in mingw*) AC_SUBST(OFSTREAMOBSERVER_SELECT_M, "OFStreamObserver_select.m") ;; esac | > > > > > > > > > > | 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 | ]) AC_CHECK_FUNC(link, [ AC_DEFINE(OF_HAVE_LINK, 1, [Whether we have link()]) ]) AC_CHECK_FUNC(symlink, [ AC_DEFINE(OF_HAVE_SYMLINK, 1, [Whether we have symlink()]) ]) AC_CHECK_FUNC(pipe, [ AC_DEFINE(OF_HAVE_PIPE, 1, [Whether we have pipe()]) ]) AC_ARG_ENABLE(sockets, AS_HELP_STRING([--disable-sockets], [disable socket support])) AS_IF([test x"$enable_sockets" != x"no"], [ AC_DEFINE(OF_HAVE_SOCKETS, 1, [Whether we have sockets]) AC_SUBST(USE_SRCS_SOCKETS, '${SRCS_SOCKETS}') AC_CHECK_LIB(socket, socket, LIBS="$LIBS -lsocket") AC_CHECK_LIB(network, socket, LIBS="$LIBS -lnetwork") AC_CHECK_LIB(ws2_32, main, LIBS="$LIBS -lws2_32") AC_CHECK_HEADER(sys/socket.h, [ AC_DEFINE(OF_HAVE_SYS_SOCKET_H, 1, [Whether we have sys/socket.h]) ]) AC_CHECK_HEADERS([netinet/in.h arpa/inet.h netdb.h]) AC_CHECK_FUNC(kqueue, [ AC_DEFINE(HAVE_KQUEUE, 1, [Whether we have kqueue]) AC_SUBST(OFSTREAMOBSERVER_KQUEUE_M, "OFStreamObserver_kqueue.m") ]) AC_CHECK_HEADER(poll.h, [ AC_DEFINE(HAVE_POLL_H, 1, [Whether we have poll.h]) AC_SUBST(OFSTREAMOBSERVER_POLL_M, "OFStreamObserver_poll.m") ]) AC_CHECK_HEADER(sys/select.h, [ AC_DEFINE(HAVE_SYS_SELECT_H, 1, [Whether we have sys/select.h]) AC_SUBST(OFSTREAMOBSERVER_SELECT_M, "OFStreamObserver_select.m") ]) case "$host_os" in mingw*) AC_SUBST(OFSTREAMOBSERVER_SELECT_M, "OFStreamObserver_select.m") ;; esac |
︙ | ︙ | |||
697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 | have_threadsafe_getaddrinfo="no" ]) ]) AS_IF([test x"$have_threadsafe_getaddrinfo" = x"yes"], [ AC_DEFINE(HAVE_THREADSAFE_GETADDRINFO, 1, [Whether getaddrinfo is thread-safe]) ]) AC_MSG_RESULT($have_threadsafe_getaddrinfo) ]) ], [ AC_MSG_RESULT(no) ]) ]) AS_IF([test x"$enable_sockets" != x"no" -a x"$enable_threads" != x"no"], [ AC_SUBST(OFHTTPCLIENTTESTS_M, "OFHTTPClientTests.m") ]) case "$host" in *-*-mingw*) have_processes="yes" ;; *) | > > > | | 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 | have_threadsafe_getaddrinfo="no" ]) ]) AS_IF([test x"$have_threadsafe_getaddrinfo" = x"yes"], [ AC_DEFINE(HAVE_THREADSAFE_GETADDRINFO, 1, [Whether getaddrinfo is thread-safe]) ], [ AC_CHECK_FUNCS([h_errno hstrerror]) ]) AC_MSG_RESULT($have_threadsafe_getaddrinfo) ]) ], [ AC_MSG_RESULT(no) AC_CHECK_FUNCS([h_errno hstrerror]) ]) ]) AS_IF([test x"$enable_sockets" != x"no" -a x"$enable_threads" != x"no"], [ AC_SUBST(OFHTTPCLIENTTESTS_M, "OFHTTPClientTests.m") ]) case "$host" in *-*-mingw*) have_processes="yes" ;; *) AC_CHECK_FUNCS([fork dup2 execvp kill], [ if test x"$ac_cv_func_fork" = x"yes" \ -a x"$ac_cv_func_pipe" = x"yes" \ -a x"$ac_cv_func_dup2" = x"yes" \ -a x"$ac_cv_func_execvp" = x"yes" \ -a x"$ac_cv_func_kill" = x"yes"; then have_processes="yes" fi |
︙ | ︙ |
Modified src/OFStreamObserver.h from [968a82ac04] to [9d097b3bbf].
︙ | ︙ | |||
15 16 17 18 19 20 21 22 23 24 25 26 27 28 | */ #import "OFObject.h" #ifndef OF_HAVE_SOCKETS # error No sockets available! #endif #ifdef _WIN32 # include <winsock2.h> #endif @class OFStream; @class OFMutableArray; | > > > > | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | */ #import "OFObject.h" #ifndef OF_HAVE_SOCKETS # error No sockets available! #endif #ifdef OF_HAVE_SYS_SOCKET_H # include <sys/socket.h> #endif #ifdef _WIN32 # include <winsock2.h> #endif @class OFStream; @class OFMutableArray; |
︙ | ︙ | |||
82 83 84 85 86 87 88 | OFMutableArray *_writeStreams; __unsafe_unretained OFStream **_FDToStream; size_t _maxFD; OFMutableArray *_queue; OFDataArray *_queueInfo, *_queueFDs; id <OFStreamObserverDelegate> _delegate; int _cancelFD[2]; | | | 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | OFMutableArray *_writeStreams; __unsafe_unretained OFStream **_FDToStream; size_t _maxFD; OFMutableArray *_queue; OFDataArray *_queueInfo, *_queueFDs; id <OFStreamObserverDelegate> _delegate; int _cancelFD[2]; #ifndef OF_HAVE_PIPE struct sockaddr_in _cancelAddr; #endif #ifdef OF_HAVE_THREADS OFMutex *_mutex; #endif } |
︙ | ︙ |
Modified src/OFStreamObserver.m from [4b5320c792] to [acce8334f0].
︙ | ︙ | |||
25 26 27 28 29 30 31 | #include <assert.h> #import "OFStreamObserver.h" #import "OFArray.h" #import "OFDictionary.h" #import "OFStream.h" #import "OFDataArray.h" | | | | 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | #include <assert.h> #import "OFStreamObserver.h" #import "OFArray.h" #import "OFDictionary.h" #import "OFStream.h" #import "OFDataArray.h" #ifndef OF_HAVE_PIPE # import "OFStreamSocket.h" #endif #ifdef OF_HAVE_THREADS # import "OFMutex.h" #endif #import "OFDate.h" #ifdef HAVE_KQUEUE |
︙ | ︙ | |||
94 95 96 97 98 99 100 | #endif - init { self = [super init]; @try { | | | | | | 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | #endif - init { self = [super init]; @try { #ifndef OF_HAVE_PIPE struct sockaddr_in cancelAddr2; socklen_t cancelAddrLen; #endif _readStreams = [[OFMutableArray alloc] init]; _writeStreams = [[OFMutableArray alloc] init]; _queue = [[OFMutableArray alloc] init]; _queueInfo = [[OFDataArray alloc] initWithItemSize: sizeof(int)]; _queueFDs = [[OFDataArray alloc] initWithItemSize: sizeof(int)]; #ifdef OF_HAVE_PIPE if (pipe(_cancelFD)) @throw [OFInitializationFailedException exceptionWithClass: [self class]]; #else /* Make sure network has been initialized */ [OFStreamSocket class]; _cancelFD[0] = socket(AF_INET, SOCK_DGRAM, 0); _cancelFD[1] = socket(AF_INET, SOCK_DGRAM, 0); if (_cancelFD[0] == INVALID_SOCKET || _cancelFD[1] == INVALID_SOCKET) @throw [OFInitializationFailedException |
︙ | ︙ | |||
134 135 136 137 138 139 140 | if (bind(_cancelFD[0], (struct sockaddr*)&_cancelAddr, sizeof(_cancelAddr)) || bind(_cancelFD[1], (struct sockaddr*)&cancelAddr2, sizeof(cancelAddr2))) @throw [OFInitializationFailedException exceptionWithClass: [self class]]; cancelAddrLen = sizeof(_cancelAddr); | < | 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | if (bind(_cancelFD[0], (struct sockaddr*)&_cancelAddr, sizeof(_cancelAddr)) || bind(_cancelFD[1], (struct sockaddr*)&cancelAddr2, sizeof(cancelAddr2))) @throw [OFInitializationFailedException exceptionWithClass: [self class]]; cancelAddrLen = sizeof(_cancelAddr); if (getsockname(_cancelFD[0], (struct sockaddr*)&_cancelAddr, &cancelAddrLen)) @throw [OFInitializationFailedException exceptionWithClass: [self class]]; #endif _maxFD = _cancelFD[0]; |
︙ | ︙ | |||
383 384 385 386 387 388 389 | - (bool)observeUntilDate: (OFDate*)date { return [self observeForTimeInterval: [date timeIntervalSinceNow]]; } - (void)cancel { | | | 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 | - (bool)observeUntilDate: (OFDate*)date { return [self observeForTimeInterval: [date timeIntervalSinceNow]]; } - (void)cancel { #ifdef OF_HAVE_PIPE OF_ENSURE(write(_cancelFD[1], "", 1) > 0); #else OF_ENSURE(sendto(_cancelFD[1], "", 1, 0, (struct sockaddr*)&_cancelAddr, sizeof(_cancelAddr)) > 0); #endif } |
︙ | ︙ |
Modified src/OFStreamObserver_poll.m from [da5230bc72] to [047427a85c].
︙ | ︙ | |||
15 16 17 18 19 20 21 | */ #include "config.h" #define __NO_EXT_QNX #include <unistd.h> | > > | > | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | */ #include "config.h" #define __NO_EXT_QNX #include <unistd.h> #ifdef HAVE_POLL_H # include <poll.h> #endif #import "OFStreamObserver_poll.h" #import "OFDataArray.h" #import "OFOutOfRangeException.h" #import "autorelease.h" |
︙ | ︙ |
Modified src/OFStreamSocket.m from [f99014d0c7] to [05982c597a].
︙ | ︙ | |||
20 21 22 23 24 25 26 | #include <string.h> #include <unistd.h> #include <errno.h> | < | > < < < < | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | #include <string.h> #include <unistd.h> #include <errno.h> #include <sys/types.h> #ifdef OF_HAVE_SYS_SOCKET_H # include <sys/socket.h> #endif #import "OFStreamSocket.h" #import "OFInitializationFailedException.h" #import "OFNotConnectedException.h" #import "OFReadFailedException.h" #import "OFSetOptionFailedException.h" #import "OFWriteFailedException.h" #ifndef INVALID_SOCKET |
︙ | ︙ |
Modified src/OFTCPSocket.h from [63a39507d8] to [720d96e946].
︙ | ︙ | |||
17 18 19 20 21 22 23 | #ifndef __STDC_LIMIT_MACROS # define __STDC_LIMIT_MACROS #endif #ifndef __STDC_CONSTANT_MACROS # define __STDC_CONSTANT_MACROS #endif | | < < | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | #ifndef __STDC_LIMIT_MACROS # define __STDC_LIMIT_MACROS #endif #ifndef __STDC_CONSTANT_MACROS # define __STDC_CONSTANT_MACROS #endif #ifdef OF_HAVE_SYS_SOCKET_H # include <sys/socket.h> #endif #import "OFStreamSocket.h" #ifdef _WIN32 # include <ws2tcpip.h> #endif |
︙ | ︙ |
Modified src/OFTCPSocket.m from [2065e219ce] to [f93320b4b5].
︙ | ︙ | |||
23 24 25 26 27 28 29 | #include <stdlib.h> #include <string.h> #include <unistd.h> #include <assert.h> | | > > > > | 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | #include <stdlib.h> #include <string.h> #include <unistd.h> #include <assert.h> #ifdef HAVE_NETINET_IN_H # include <netinet/in.h> #endif #ifdef HAVE_ARPA_INET_H # include <arpa/inet.h> #endif #ifdef HAVE_NETDB_H # include <netdb.h> #endif #import "OFTCPSocket.h" #import "OFTCPSocket+SOCKS5.h" #import "OFString.h" #ifdef OF_HAVE_THREADS |
︙ | ︙ | |||
64 65 66 67 68 69 70 71 72 73 74 75 76 77 | # ifndef AI_NUMERICSERV # define AI_NUMERICSERV 0 # endif # ifndef AI_NUMERICHOST # define AI_NUMERICHOST 0 # endif #endif #if defined(OF_HAVE_THREADS) && !defined(HAVE_THREADSAFE_GETADDRINFO) # import "OFMutex.h" # import "OFDataArray.h" static OFMutex *mutex = nil; #endif | > > > > | 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | # ifndef AI_NUMERICSERV # define AI_NUMERICSERV 0 # endif # ifndef AI_NUMERICHOST # define AI_NUMERICHOST 0 # endif #endif #ifndef SOMAXCONN # define SOMAXCONN 32 #endif #if defined(OF_HAVE_THREADS) && !defined(HAVE_THREADSAFE_GETADDRINFO) # import "OFMutex.h" # import "OFDataArray.h" static OFMutex *mutex = nil; #endif |
︙ | ︙ |
Modified src/exceptions/common.h from [19aae6e6f7] to [082aeff5c0].
︙ | ︙ | |||
11 12 13 14 15 16 17 18 19 20 | * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include <string.h> #import "macros.h" | > | < | | | > | | | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include <string.h> #include <errno.h> #import "macros.h" #ifdef HAVE_NETDB_H # include <netdb.h> #endif #ifndef _WIN32 # define GET_ERRNO errno # ifdef OF_HAVE_SOCKETS # if !defined(HAVE_THREADSAFE_GETADDRINFO) && defined(HAVE_H_ERRNO) # define GET_AT_ERRNO h_errno # else # define GET_AT_ERRNO errno # endif # define GET_SOCK_ERRNO errno # endif # define ERRFMT "Error string was: %s" # define ERRPARAM strerror(_errNo) # ifdef OF_HAVE_SOCKETS # if !defined(HAVE_THREADSAFE_GETADDRINFO) && defined(HAVE_HSTRERROR) # define AT_ERRPARAM hstrerror(_errNo) # else # define AT_ERRPARAM strerror(_errNo) # endif # endif #else # include <windows.h> |
︙ | ︙ |
Modified src/objfw-defs.h.in from [3af4f4e1ad] to [226b05630f].
1 2 3 4 5 6 7 8 9 10 11 12 13 | #undef OF_APPLE_RUNTIME #undef OF_BIG_ENDIAN #undef OF_FLOAT_BIG_ENDIAN #undef OF_HAVE_ASPRINTF #undef OF_HAVE_ATOMIC_OPS #undef OF_HAVE_CHMOD #undef OF_HAVE_CHOWN #undef OF_HAVE_COMPILER_TLS #undef OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR #undef OF_HAVE_GCC_ATOMIC_OPS #undef OF_HAVE_LINK #undef OF_HAVE_OSATOMIC #undef OF_HAVE_OSATOMIC_64 | | > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | #undef OF_APPLE_RUNTIME #undef OF_BIG_ENDIAN #undef OF_FLOAT_BIG_ENDIAN #undef OF_HAVE_ASPRINTF #undef OF_HAVE_ATOMIC_OPS #undef OF_HAVE_CHMOD #undef OF_HAVE_CHOWN #undef OF_HAVE_COMPILER_TLS #undef OF_HAVE_FORWARDING_TARGET_FOR_SELECTOR #undef OF_HAVE_GCC_ATOMIC_OPS #undef OF_HAVE_LINK #undef OF_HAVE_OSATOMIC #undef OF_HAVE_OSATOMIC_64 #undef OF_HAVE_PIPE #undef OF_HAVE_PLUGINS #undef OF_HAVE_PROCESSES #undef OF_HAVE_PTHREADS #undef OF_HAVE_PTHREAD_SPINLOCKS #undef OF_HAVE_RECURSIVE_PTHREAD_MUTEXES #undef OF_HAVE_SCHED_YIELD #undef OF_HAVE_SOCKETS #undef OF_HAVE_SYMLINK #undef OF_HAVE_SYS_SOCKET_H #undef OF_HAVE_THREADS #undef OF_OBJFW_RUNTIME #undef SIZE_MAX |