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

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

#1 change timeout mechanism from setting socket option to using select

File size: 1.9 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
16#include <stddef.h>
17
18/** 타임아웃을 설정하지 않음 */
19#define CF_SOCKET_NO_TIMEOUT -1
20
21/** 호스트 정보 */
22typedef struct cf_socket_hostinfo {
23 char address[128]; /**< 원격 호스트 주소 */
24 unsigned short port; /**< 원격 호스트 포트 */
25} CF_Socket_HostInfo;
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31CF_EXPORT CF_BOOL
32CF_Socket_IsInitialized (void);
33
34CF_EXPORT int
35CF_Socket_Initialize (void);
36
37CF_EXPORT int
38CF_Socket_Finalize (void);
39
40CF_EXPORT int
41CF_Socket_Close (const int sock);
42
43CF_EXPORT int
44CF_Socket_SetOption (const int sock,
45 const int optname,
46 const void * optval,
47 const size_t optlen);
48
49CF_EXPORT int
50CF_Socket_GetOption (const int sock,
51 const int optname,
52 void * optval,
53 size_t * optlen);
54
55CF_EXPORT int
56CF_Socket_Connect (const char * ip,
57 const unsigned short port);
58
59CF_EXPORT int
60CF_Socket_ConnectTimeout (const char * ip,
61 const unsigned short port,
62 const int timeout);
63
64CF_EXPORT int
65CF_Socket_Server (const unsigned short port,
66 const int backlog);
67
68CF_EXPORT int
69CF_Socket_Accept (const int sock,
70 CF_Socket_HostInfo * host);
71
72CF_EXPORT int
73CF_Socket_Send (const int sock,
74 const void * buf,
75 const int len);
76
77CF_EXPORT int
78CF_Socket_SendTimeout (const int sock,
79 const void * buf,
80 const int len,
81 const int timeout);
82
83CF_EXPORT int
84CF_Socket_Recv (const int sock,
85 void * buf,
86 const int len);
87
88CF_EXPORT int
89CF_Socket_RecvTimeout (const int sock,
90 void * buf,
91 const int len,
92 const int timeout);
93
94#ifdef __cplusplus
95}
96#endif
97
98#endif // #ifndef __CF_SOCKET_H__
Note: See TracBrowser for help on using the repository browser.