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

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

#1 change interface of log from context to id-number

File size: 1.6 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#ifdef _WIN32
28typedef int socklen_t;
29#endif // #ifdef _WIN32
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
35CF_EXPORT CF_BOOL
36CF_Socket_IsInitialized (void);
37
38CF_EXPORT int
39CF_Socket_Initialize (void);
40
41CF_EXPORT int
42CF_Socket_Finalize (void);
43
44CF_EXPORT int
45CF_Socket_Close (const int sock);
46
47CF_EXPORT int
48CF_Socket_SetOption (const int sock,
49 const int optname,
50 const void * optval,
51 const size_t optlen);
52
53CF_EXPORT int
54CF_Socket_GetOption (const int sock,
55 const int optname,
56 void * optval,
57 size_t * optlen);
58
59CF_EXPORT int
60CF_Socket_SetTimeout (const int sock,
61 const int timeout);
62
63CF_EXPORT int
64CF_Socket_Connect (const char * ip,
65 const unsigned short port);
66
67CF_EXPORT int
68CF_Socket_Server (const unsigned short port,
69 const int backlog);
70
71CF_EXPORT int
72CF_Socket_Accept (const int sock,
73 struct sockaddr_in * address);
74
75CF_EXPORT int
76CF_Socket_Send (const int sock,
77 const void * buf,
78 const int len);
79
80CF_EXPORT int
81CF_Socket_Recv (const int sock,
82 void * buf,
83 const int len);
84
85#ifdef __cplusplus
86}
87#endif
88
89#endif // #ifndef __CF_SOCKET_H__
Note: See TracBrowser for help on using the repository browser.