diff options
author | Nick Mathewson <nickm@torproject.org> | 2006-09-19 20:41:31 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2006-09-19 20:41:31 +0000 |
commit | 93beeac01d27c3150cc998331ab79354c311bd8f (patch) | |
tree | 9ff5d506c6e4f74a01b54e26225b0485ca30eb38 /src/common/compat.h | |
parent | 8648b1133b72f384fc588208c0439a1aff30ec03 (diff) | |
download | tor-93beeac01d27c3150cc998331ab79354c311bd8f.tar.gz tor-93beeac01d27c3150cc998331ab79354c311bd8f.zip |
Merge in some bsockets calls, all wrapped inside #if defined(USE_BSOCKETS)
svn:r8427
Diffstat (limited to 'src/common/compat.h')
-rw-r--r-- | src/common/compat.h | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/common/compat.h b/src/common/compat.h index 7ed2e62e62..5567f5e9c1 100644 --- a/src/common/compat.h +++ b/src/common/compat.h @@ -199,7 +199,9 @@ int touch_file(const char *fname); #endif /* ===== Net compatibility */ -#ifdef MS_WINDOWS +#ifdef USE_BSOCKETS +#define tor_close_socket(s) bclose(s) +#elif defined(MS_WINDOWS) /** On Windows, you have to call close() on fds returned by open(), * and closesocket() on fds returned by socket(). On Unix, everything * gets close()'d. We abstract this difference by always using @@ -211,6 +213,14 @@ int touch_file(const char *fname); #define tor_close_socket(s) close(s) #endif +#ifdef USE_BSOCKETS +#define tor_socket_send(s, buf, len, flags) bsend(s, buf, len, flags) +#define tor_socket_recv(s, buf, len, flags) brecv(s, buf, len, flags) +#else +#define tor_socket_send(s, buf, len, flags) send(s, buf, len, flags) +#define tor_socket_recv(s, buf, len, flags) recv(s, buf, len, flags) +#endif + #if (SIZEOF_SOCKLEN_T == 0) typedef int socklen_t; #endif @@ -227,7 +237,7 @@ int network_init(void); * errnos against expected values, and use tor_socket_errno to find * the actual errno after a socket operation fails. */ -#ifdef MS_WINDOWS +#if defined(MS_WINDOWS) && !defined(USE_BSOCKETS) /** Return true if e is EAGAIN or the local equivalent. */ #define ERRNO_IS_EAGAIN(e) ((e) == EAGAIN || (e) == WSAEWOULDBLOCK) /** Return true if e is EINPROGRESS or the local equivalent. */ |