00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef PEEKABOT_SOCKETS_HH
00013 #define PEEKABOT_SOCKETS_HH
00014
00015
00016 #include "Types.hh"
00017
00018
00019
00020 #ifdef _WIN32
00021 # include <winsock.h>
00022 # include <winsock2.h>
00023 # define socklen_t int
00024 # ifndef EINPROGRESS
00025 # define EINPROGRESS WSAEINPROGRESS
00026 # endif
00027 # ifndef EINTR
00028 # define EINTR WSAEINTR
00029 # endif
00030 #else
00031 # include <sys/select.h>
00032 # include <sys/socket.h>
00033 # include <sys/types.h>
00034 # include <unistd.h>
00035 # include <fcntl.h>
00036 # include <sys/time.h>
00037 # include <netinet/in.h>
00038 # include <netinet/tcp.h>
00039 # include <netdb.h>
00040 # include <arpa/inet.h>
00041 # include <errno.h>
00042 # define INVALID_SOCKET -1
00043 # define SOCKET_ERROR -1
00044 #endif
00045
00046
00047 #ifndef MSG_NOSIGNAL
00048 # define MSG_NOSIGNAL 0
00049 #endif
00050
00051 namespace peekabot
00052 {
00053 namespace sockets
00054 {
00055 #ifdef _WIN32
00056 typedef SOCKET SocketType;
00057 typedef char* BufType;
00058 #else
00059 typedef int SocketType;
00060 typedef void* BufType;
00061 #endif
00062
00063 void set_nonblocking(SocketType sock);
00064
00065 void sockets_init();
00066
00067 void sockets_cleanup();
00068
00069 int get_socket_errno();
00070
00071 int close_socket(SocketType socket);
00072 }
00073 }
00074
00075 #endif // PEEKABOT_SOCKETS_HH