00001 #ifndef TCP_H 00002 #define TCP_H 00003 00004 #ifdef WINSOCK 00005 # include <winsock.h> 00006 # define TCP_SOCKET SOCKET 00007 # define TCP_ERROR SOCKET_ERROR 00008 # define SHUT_RD SD_RECEIVE 00009 # define SHUT_WR SD_SEND 00010 # define SHUT_RDWR SD_BOTH 00011 #else 00012 # include <sys/types.h> 00013 # include <sys/socket.h> 00014 # define TCP_SOCKET int 00015 # define TCP_ERROR -1 00016 #endif 00017 00018 #define TCP_CONNECTION TCP_SOCKET 00019 00020 TCP_CONNECTION tcp_connect(const char *host, int port); 00021 int tcp_close(TCP_CONNECTION conn); 00022 int tcp_read(TCP_CONNECTION conn, void *buf, int len); 00023 int tcp_write(TCP_CONNECTION conn, const void *buf, int len); 00024 int tcp_setblocking(TCP_CONNECTION conn, int blocking); 00025 TCP_SOCKET tcp_listen(const char *host, int port); 00026 TCP_CONNECTION tcp_accept(TCP_SOCKET sock); 00027 00028 #define tcp_getpeername getpeername 00029 #define tcp_getsockname getsockname 00030 #define tcp_recv recv 00031 #define tcp_send send 00032 #define tcp_shutdown shutdown 00033 00034 #endif /* ndef TCP_H */