aboutsummaryrefslogtreecommitdiffstats
path: root/sockets.h
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2008-10-21 07:00:00 -0700
committerThe Android Open Source Project <initial-contribution@android.com>2008-10-21 07:00:00 -0700
commit55f4e4a5ec657a017e3bf75299ad71fd1c968dd3 (patch)
tree550ce922ea0e125ac6a9738210ce2939bf2fe901 /sockets.h
parent413f05aaf54fa08c0ae7e997327a4f4a473c0a8d (diff)
downloadexternal_qemu-55f4e4a5ec657a017e3bf75299ad71fd1c968dd3.zip
external_qemu-55f4e4a5ec657a017e3bf75299ad71fd1c968dd3.tar.gz
external_qemu-55f4e4a5ec657a017e3bf75299ad71fd1c968dd3.tar.bz2
Initial Contribution
Diffstat (limited to 'sockets.h')
-rw-r--r--sockets.h73
1 files changed, 73 insertions, 0 deletions
diff --git a/sockets.h b/sockets.h
new file mode 100644
index 0000000..c1f6d80
--- /dev/null
+++ b/sockets.h
@@ -0,0 +1,73 @@
+/* Copyright (C) 2007-2008 The Android Open Source Project
+**
+** This software is licensed under the terms of the GNU General Public
+** License version 2, as published by the Free Software Foundation, and
+** may be copied, distributed, and modified under those terms.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+*/
+/* headers to use the BSD sockets */
+#ifndef QEMU_SOCKET_H
+#define QEMU_SOCKET_H
+
+#ifdef _WIN32
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#include <winsock2.h>
+#include <ws2tcpip.h>
+
+#define socket_errno WSAGetLastError()
+#define socket_errstr() socket_strerr()
+
+#undef EINTR
+#define EWOULDBLOCK WSAEWOULDBLOCK
+#define EINTR WSAEINTR
+#define EINPROGRESS WSAEINPROGRESS
+
+extern const char* socket_strerr(void);
+
+#else
+
+/* if this code is included from slirp/ sources, don't include the
+ * system header files because this might conflict with some of the
+ * slirp definitions
+ */
+#include <errno.h>
+#ifndef SLIRP_COMPILATION
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netinet/tcp.h>
+#include <netdb.h>
+#endif
+
+#define socket_errno errno
+#define socket_errstr() strerror(errno)
+
+#endif /* !_WIN32 */
+
+int socket_init( void );
+
+int socket_get_type(int fd);
+
+/* set SO_REUSEADDR on Unix, SO_EXCLUSIVEADDR on Windows */
+int socket_set_xreuseaddr(int fd);
+int socket_set_nonblock(int fd);
+int socket_set_blocking(int fd);
+int socket_set_lowlatency(int fd);
+int socket_set_oobinline(int fd);
+void socket_close(int fd);
+
+int socket_loopback_server( int port, int type );
+int socket_loopback_client( int port, int type );
+#ifndef _WIN32
+int socket_unix_server( const char* name, int type );
+int socket_unix_client( const char* name, int type );
+#endif
+int socket_network_client( const char* host, int port, int type );
+int socket_anyaddr_server( int port, int type );
+int socket_accept_any( int server_fd );
+
+#endif /* QEMU_SOCKET_H */