8585 #endif /* HAVE_ECC */
8686#endif /*HAVE_PK_CALLBACKS */
8787
88- #ifdef USE_WINDOWS_API
88+ #ifdef __WATCOMC__
89+ #define SNPRINTF snprintf
90+ #if defined(__NT__ )
91+ #include <winsock2.h>
92+ #include <ws2tcpip.h>
93+ #include <process.h>
94+ #ifdef TEST_IPV6 /* don't require newer SDK for IPV4 */
95+ #include <wspiapi.h>
96+ #endif
97+ #define SOCKET_T SOCKET
98+ #define XSLEEP_MS (t ) Sleep(t)
99+ #elif defined(__OS2__ )
100+ #include <netdb.h>
101+ #include <sys/ioctl.h>
102+ #include <tcpustd.h>
103+ #define SOCKET_T int
104+ #elif defined(__UNIX__ )
105+ #include <string.h>
106+ #include <netdb.h>
107+ #include <netinet/tcp.h>
108+ #ifndef WOLFSSL_NDS
109+ #include <sys/ioctl.h>
110+ #endif
111+ #include <time.h>
112+ #include <sys/time.h>
113+ #ifdef HAVE_PTHREAD
114+ #include <pthread.h>
115+ #endif
116+ #define SOCKET_T int
117+ #ifndef SO_NOSIGPIPE
118+ #include <signal.h> /* ignore SIGPIPE */
119+ #endif
120+
121+ #define XSLEEP_MS (m ) \
122+ { \
123+ struct timespec req = { (m)/1000, ((m) % 1000) * 1000 }; \
124+ nanosleep( &req, NULL ); \
125+ }
126+ #endif
127+ #elif defined(USE_WINDOWS_API )
89128 #include <winsock2.h>
129+ #include <ws2tcpip.h>
90130 #include <process.h>
91131 #ifdef TEST_IPV6 /* don't require newer SDK for IPV4 */
92- #include <ws2tcpip.h>
93132 #include <wspiapi.h>
94133 #endif
95134 #define SOCKET_T SOCKET
@@ -1429,7 +1468,7 @@ static WC_INLINE void tcp_socket(SOCKET_T* sockfd, int udp, int sctp)
14291468 err_sys_with_errno ("socket failed\n" );
14301469 }
14311470
1432- #ifndef USE_WINDOWS_API
1471+ #if !defined( USE_WINDOWS_API ) && !defined( __WATCOMC__ ) && !defined( __OS2__ )
14331472#ifdef SO_NOSIGPIPE
14341473 {
14351474 int on = 1 ;
@@ -1457,7 +1496,7 @@ static WC_INLINE void tcp_socket(SOCKET_T* sockfd, int udp, int sctp)
14571496 err_sys_with_errno ("setsockopt TCP_NODELAY failed\n" );
14581497 }
14591498#endif
1460- #endif /* USE_WINDOWS_API */
1499+ #endif /* !defined( USE_WINDOWS_API) && !defined(__WATCOMC__) && ... */
14611500}
14621501
14631502#if defined(WOLFSSL_WOLFSENTRY_HOOKS ) && defined(WOLFSENTRY_H )
@@ -1801,6 +1840,10 @@ static WC_INLINE void tcp_set_nonblocking(SOCKET_T* sockfd)
18011840 || defined (WOLFSSL_TIRTOS )|| defined(WOLFSSL_VXWORKS ) \
18021841 || defined(WOLFSSL_ZEPHYR )
18031842 /* non blocking not supported, for now */
1843+ #elif defined(__WATCOMC__ ) && defined(__OS2__ )
1844+ int blocking = 1 ;
1845+ if (ioctl (* sockfd , FIONBIO , & blocking ) == -1 )
1846+ err_sys_with_errno ("ioctl failed" );
18041847 #else
18051848 int flags = fcntl (* sockfd , F_GETFL , 0 );
18061849 if (flags < 0 )
@@ -1822,6 +1865,10 @@ static WC_INLINE void tcp_set_blocking(SOCKET_T* sockfd)
18221865 || defined (WOLFSSL_TIRTOS )|| defined(WOLFSSL_VXWORKS ) \
18231866 || defined(WOLFSSL_ZEPHYR )
18241867 /* non blocking not supported, for now */
1868+ #elif defined(__WATCOMC__ ) && defined(__OS2__ )
1869+ int blocking = 0 ;
1870+ if (ioctl (* sockfd , FIONBIO , & blocking ) == -1 )
1871+ err_sys_with_errno ("ioctl failed" );
18251872 #else
18261873 int flags = fcntl (* sockfd , F_GETFL , 0 );
18271874 if (flags < 0 )
0 commit comments