source: libcf/trunk/include/cf_socket.h@ 6

Last change on this file since 6 was 6, checked in by cheese, 11 years ago

#1 add debug util and arrange some code

File size: 2.2 KB
Line 
1/**
2 * cf_socket.h
3 */
4#ifndef __CF_SOCKET_H__
5#define __CF_SOCKET_H__
6
7#include "cf_base.h"
8#include <stddef.h>
9
10#define CF_ERROR_SOCKET_INITIALIZE CF_ERROR_SOCKET - 1
11#define CF_ERROR_SOCKET_NOT_INITIALIZED CF_ERROR_SOCKET - 2
12#define CF_ERROR_SOCKET_FINALIZE CF_ERROR_SOCKET - 3
13#define CF_ERROR_SOCKET_CLOSE CF_ERROR_SOCKET - 4
14#define CF_ERROR_SOCKET_CREATE CF_ERROR_SOCKET - 5
15#define CF_ERROR_SOCKET_CONNECT CF_ERROR_SOCKET - 6
16#define CF_ERROR_SOCKET_SET_OPTION CF_ERROR_SOCKET - 7
17#define CF_ERROR_SOCKET_GET_OPTION CF_ERROR_SOCKET - 8
18#define CF_ERROR_SOCKET_SET_TIMEOUT CF_ERROR_SOCKET - 9
19#define CF_ERROR_SOCKET_INVALID_ARGS CF_ERROR_SOCKET - 10
20#define CF_ERROR_SOCKET_INVALID_SOCKET CF_ERROR_SOCKET - 11
21#define CF_ERROR_SOCKET_GET_HOST CF_ERROR_SOCKET - 12
22#define CF_ERROR_SOCKET_BIND CF_ERROR_SOCKET - 13
23#define CF_ERROR_SOCKET_LISTEN CF_ERROR_SOCKET - 14
24#define CF_ERROR_SOCKET_ACCEPT CF_ERROR_SOCKET - 15
25#define CF_ERROR_SOCKET_SEND CF_ERROR_SOCKET - 16
26#define CF_ERROR_SOCKET_RECV CF_ERROR_SOCKET - 17
27
28#ifdef _WIN32
29typedef int socklen_t;
30#endif // #ifdef _WIN32
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
36CF_EXPORT CF_BOOL
37CF_Socket_IsInitialized (void);
38
39CF_EXPORT int
40CF_Socket_Initialize (void);
41
42CF_EXPORT int
43CF_Socket_Finalize (void);
44
45CF_EXPORT int
46CF_Socket_Close (const int sock);
47
48CF_EXPORT int
49CF_Socket_SetOption (const int sock,
50 const int optname,
51 const void * optval,
52 const size_t optlen);
53
54CF_EXPORT int
55CF_Socket_GetOption (const int sock,
56 const int optname,
57 void * optval,
58 size_t * optlen);
59
60CF_EXPORT int
61CF_Socket_SetTimeout (const int sock,
62 const int timeout);
63
64CF_EXPORT int
65CF_Socket_Connect (const char * ip,
66 const unsigned short port);
67
68CF_EXPORT int
69CF_Socket_Server (const unsigned short port,
70 const int backlog);
71
72CF_EXPORT int
73CF_Socket_Accept (const int sock,
74 void * address /* struct sockaddr_in * */);
75
76CF_EXPORT int
77CF_Socket_Send (const int sock,
78 const void * buf,
79 const int len);
80
81CF_EXPORT int
82CF_Socket_Recv (const int sock,
83 void * buf,
84 const int len);
85
86#ifdef __cplusplus
87}
88#endif
89
90#endif // #ifndef __CF_SOCKET_H__
Note: See TracBrowser for help on using the repository browser.