/** * cf_socket.h */ #ifndef __CF_SOCKET_H__ #define __CF_SOCKET_H__ #include "cf_base.h" #include #ifdef _WIN32 # include #else # include # include # include # include # include #endif #define CF_ERROR_SOCKET_INITIALIZE CF_ERROR_SOCKET - 1 #define CF_ERROR_SOCKET_NOT_INITIALIZED CF_ERROR_SOCKET - 2 #define CF_ERROR_SOCKET_FINALIZE CF_ERROR_SOCKET - 3 #define CF_ERROR_SOCKET_CLOSE CF_ERROR_SOCKET - 4 #define CF_ERROR_SOCKET_CREATE CF_ERROR_SOCKET - 5 #define CF_ERROR_SOCKET_CONNECT CF_ERROR_SOCKET - 6 #define CF_ERROR_SOCKET_SET_OPTION CF_ERROR_SOCKET - 7 #define CF_ERROR_SOCKET_GET_OPTION CF_ERROR_SOCKET - 8 #define CF_ERROR_SOCKET_SET_TIMEOUT CF_ERROR_SOCKET - 9 #define CF_ERROR_SOCKET_INVALID_ARGS CF_ERROR_SOCKET - 10 #define CF_ERROR_SOCKET_INVALID_SOCKET CF_ERROR_SOCKET - 11 #define CF_ERROR_SOCKET_GET_HOST CF_ERROR_SOCKET - 12 #define CF_ERROR_SOCKET_BIND CF_ERROR_SOCKET - 13 #define CF_ERROR_SOCKET_LISTEN CF_ERROR_SOCKET - 14 #define CF_ERROR_SOCKET_ACCEPT CF_ERROR_SOCKET - 15 #define CF_ERROR_SOCKET_SEND CF_ERROR_SOCKET - 16 #define CF_ERROR_SOCKET_RECV CF_ERROR_SOCKET - 17 #ifdef _WIN32 typedef int socklen_t; #endif // #ifdef _WIN32 #ifdef __cplusplus extern "C" { #endif CF_EXPORT CF_BOOL CF_Socket_IsInitialized (void); CF_EXPORT int CF_Socket_Initialize (void); CF_EXPORT int CF_Socket_Finalize (void); CF_EXPORT int CF_Socket_Close (const int sock); CF_EXPORT int CF_Socket_SetOption (const int sock, const int optname, const void * optval, const size_t optlen); CF_EXPORT int CF_Socket_GetOption (const int sock, const int optname, void * optval, size_t * optlen); CF_EXPORT int CF_Socket_SetTimeout (const int sock, const int timeout); CF_EXPORT int CF_Socket_Connect (const char * ip, const unsigned short port); CF_EXPORT int CF_Socket_Server (const unsigned short port, const int backlog); CF_EXPORT int CF_Socket_Accept (const int sock, struct sockaddr_in * address); CF_EXPORT int CF_Socket_Send (const int sock, const void * buf, const int len); CF_EXPORT int CF_Socket_Recv (const int sock, void * buf, const int len); #ifdef __cplusplus } #endif #endif // #ifndef __CF_SOCKET_H__