[4] | 1 | /**
|
---|
[26] | 2 | * @file cf_socket.h
|
---|
| 3 | * @author myusgun <myusgun@gmail.com>
|
---|
| 4 | * @version 0.1
|
---|
[34] | 5 | *
|
---|
| 6 | * @remark TCP 소켓만 지원됨
|
---|
| 7 | *
|
---|
[35] | 8 | * @example socket_server.c
|
---|
| 9 | * @example socket_client.c
|
---|
[4] | 10 | */
|
---|
| 11 | #ifndef __CF_SOCKET_H__
|
---|
| 12 | #define __CF_SOCKET_H__
|
---|
| 13 |
|
---|
| 14 | #include "cf_base.h"
|
---|
[46] | 15 |
|
---|
[4] | 16 | #include <stddef.h>
|
---|
| 17 |
|
---|
[46] | 18 | /** 타임아웃을 설정하지 않음 */
|
---|
| 19 | #define CF_SOCKET_NO_TIMEOUT -1
|
---|
[21] | 20 |
|
---|
[46] | 21 | /** 호스트 정보 */
|
---|
| 22 | typedef struct cf_socket_hostinfo {
|
---|
| 23 | char address[128]; /**< 원격 호스트 주소 */
|
---|
| 24 | unsigned short port; /**< 원격 호스트 포트 */
|
---|
| 25 | } CF_Socket_HostInfo;
|
---|
[6] | 26 |
|
---|
[4] | 27 | #ifdef __cplusplus
|
---|
| 28 | extern "C" {
|
---|
| 29 | #endif
|
---|
| 30 |
|
---|
[6] | 31 | CF_EXPORT CF_BOOL
|
---|
[46] | 32 | CF_Socket_IsInitialized (void);
|
---|
[4] | 33 |
|
---|
| 34 | CF_EXPORT int
|
---|
[46] | 35 | CF_Socket_Initialize (void);
|
---|
[4] | 36 |
|
---|
| 37 | CF_EXPORT int
|
---|
[46] | 38 | CF_Socket_Finalize (void);
|
---|
[4] | 39 |
|
---|
| 40 | CF_EXPORT int
|
---|
[46] | 41 | CF_Socket_Close (const int sock);
|
---|
[4] | 42 |
|
---|
| 43 | CF_EXPORT int
|
---|
[46] | 44 | CF_Socket_SetOption (const int sock,
|
---|
| 45 | const int optname,
|
---|
| 46 | const void * optval,
|
---|
| 47 | const size_t optlen);
|
---|
[4] | 48 |
|
---|
| 49 | CF_EXPORT int
|
---|
[46] | 50 | CF_Socket_GetOption (const int sock,
|
---|
| 51 | const int optname,
|
---|
| 52 | void * optval,
|
---|
| 53 | size_t * optlen);
|
---|
[4] | 54 |
|
---|
| 55 | CF_EXPORT int
|
---|
[46] | 56 | CF_Socket_Connect (const char * ip,
|
---|
| 57 | const unsigned short port);
|
---|
[4] | 58 |
|
---|
| 59 | CF_EXPORT int
|
---|
[46] | 60 | CF_Socket_ConnectTimeout (const char * ip,
|
---|
| 61 | const unsigned short port,
|
---|
| 62 | const int timeout);
|
---|
[4] | 63 |
|
---|
| 64 | CF_EXPORT int
|
---|
[46] | 65 | CF_Socket_Server (const unsigned short port,
|
---|
| 66 | const int backlog);
|
---|
[4] | 67 |
|
---|
| 68 | CF_EXPORT int
|
---|
[46] | 69 | CF_Socket_Accept (const int sock,
|
---|
| 70 | CF_Socket_HostInfo * host);
|
---|
[4] | 71 |
|
---|
| 72 | CF_EXPORT int
|
---|
[46] | 73 | CF_Socket_Send (const int sock,
|
---|
| 74 | const void * buf,
|
---|
| 75 | const int len);
|
---|
[4] | 76 |
|
---|
| 77 | CF_EXPORT int
|
---|
[46] | 78 | CF_Socket_SendTimeout (const int sock,
|
---|
| 79 | const void * buf,
|
---|
| 80 | const int len,
|
---|
| 81 | const int timeout);
|
---|
[4] | 82 |
|
---|
[46] | 83 | CF_EXPORT int
|
---|
| 84 | CF_Socket_Recv (const int sock,
|
---|
| 85 | void * buf,
|
---|
| 86 | const int len);
|
---|
| 87 |
|
---|
| 88 | CF_EXPORT int
|
---|
| 89 | CF_Socket_RecvTimeout (const int sock,
|
---|
| 90 | void * buf,
|
---|
| 91 | const int len,
|
---|
| 92 | const int timeout);
|
---|
| 93 |
|
---|
[4] | 94 | #ifdef __cplusplus
|
---|
| 95 | }
|
---|
| 96 | #endif
|
---|
| 97 |
|
---|
| 98 | #endif // #ifndef __CF_SOCKET_H__
|
---|