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

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

#1 separate example code and doxygen comment and fix logging push logic by vfire

File size: 2.5 KB
Line 
1/**
2 * @file cf_socket.h
3 * @author myusgun <myusgun@gmail.com>
4 * @version 0.1
5 *
6 * @remark TCP 소켓만 지원됨
7 *
8 * @example socket_server.c
9 * @example socket_client.c
10 */
11#ifndef __CF_SOCKET_H__
12#define __CF_SOCKET_H__
13
14#include "cf_base.h"
15#include <stddef.h>
16
17#ifdef _WIN32
18# include <WinSock2.h>
19#else
20# include <netinet/in.h>
21# include <sys/socket.h>
22# include <arpa/inet.h>
23# include <netdb.h>
24# include <unistd.h>
25#endif
26
27#define CF_ERROR_SOCKET_INITIALIZE CF_ERROR_SOCKET - 1
28#define CF_ERROR_SOCKET_NOT_INITIALIZED CF_ERROR_SOCKET - 2
29#define CF_ERROR_SOCKET_FINALIZE CF_ERROR_SOCKET - 3
30#define CF_ERROR_SOCKET_CLOSE CF_ERROR_SOCKET - 4
31#define CF_ERROR_SOCKET_CREATE CF_ERROR_SOCKET - 5
32#define CF_ERROR_SOCKET_CONNECT CF_ERROR_SOCKET - 6
33#define CF_ERROR_SOCKET_SET_OPTION CF_ERROR_SOCKET - 7
34#define CF_ERROR_SOCKET_GET_OPTION CF_ERROR_SOCKET - 8
35#define CF_ERROR_SOCKET_SET_TIMEOUT CF_ERROR_SOCKET - 9
36#define CF_ERROR_SOCKET_INVALID_ARGS CF_ERROR_SOCKET - 10
37#define CF_ERROR_SOCKET_INVALID_SOCKET CF_ERROR_SOCKET - 11
38#define CF_ERROR_SOCKET_GET_HOST CF_ERROR_SOCKET - 12
39#define CF_ERROR_SOCKET_BIND CF_ERROR_SOCKET - 13
40#define CF_ERROR_SOCKET_LISTEN CF_ERROR_SOCKET - 14
41#define CF_ERROR_SOCKET_ACCEPT CF_ERROR_SOCKET - 15
42#define CF_ERROR_SOCKET_SEND CF_ERROR_SOCKET - 16
43#define CF_ERROR_SOCKET_RECV CF_ERROR_SOCKET - 17
44
45#ifdef _WIN32
46typedef int socklen_t;
47#endif // #ifdef _WIN32
48
49#ifdef __cplusplus
50extern "C" {
51#endif
52
53CF_EXPORT CF_BOOL
54CF_Socket_IsInitialized (void);
55
56CF_EXPORT int
57CF_Socket_Initialize (void);
58
59CF_EXPORT int
60CF_Socket_Finalize (void);
61
62CF_EXPORT int
63CF_Socket_Close (const int sock);
64
65CF_EXPORT int
66CF_Socket_SetOption (const int sock,
67 const int optname,
68 const void * optval,
69 const size_t optlen);
70
71CF_EXPORT int
72CF_Socket_GetOption (const int sock,
73 const int optname,
74 void * optval,
75 size_t * optlen);
76
77CF_EXPORT int
78CF_Socket_SetTimeout (const int sock,
79 const int timeout);
80
81CF_EXPORT int
82CF_Socket_Connect (const char * ip,
83 const unsigned short port);
84
85CF_EXPORT int
86CF_Socket_Server (const unsigned short port,
87 const int backlog);
88
89CF_EXPORT int
90CF_Socket_Accept (const int sock,
91 struct sockaddr_in * address);
92
93CF_EXPORT int
94CF_Socket_Send (const int sock,
95 const void * buf,
96 const int len);
97
98CF_EXPORT int
99CF_Socket_Recv (const int sock,
100 void * buf,
101 const int len);
102
103#ifdef __cplusplus
104}
105#endif
106
107#endif // #ifndef __CF_SOCKET_H__
Note: See TracBrowser for help on using the repository browser.