Changeset 46 in libcf for trunk/include/cf_socket.h


Ignore:
Timestamp:
03/29/13 14:40:25 (11 years ago)
Author:
cheese
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/cf_socket.h

    r40 r46  
    1313
    1414#include "cf_base.h"
     15
    1516#include <stddef.h>
    1617
    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
     18/** 타임아웃을 설정하지 않음 */
     19#define CF_SOCKET_NO_TIMEOUT        -1
    2620
    27 #ifdef _WIN32
    28 typedef int socklen_t;
    29 #endif // #ifdef _WIN32
     21/** 호스트 정보 */
     22typedef struct cf_socket_hostinfo {
     23    char            address[128];   /**< 원격 호스트 주소 */
     24    unsigned short  port;           /**< 원격 호스트 포트 */
     25} CF_Socket_HostInfo;
    3026
    3127#ifdef __cplusplus
     
    3430
    3531CF_EXPORT CF_BOOL
    36 CF_Socket_IsInitialized (void);
     32CF_Socket_IsInitialized     (void);
    3733
    3834CF_EXPORT int
    39 CF_Socket_Initialize    (void);
     35CF_Socket_Initialize        (void);
    4036
    4137CF_EXPORT int
    42 CF_Socket_Finalize      (void);
     38CF_Socket_Finalize          (void);
    4339
    4440CF_EXPORT int
    45 CF_Socket_Close         (const int sock);
     41CF_Socket_Close             (const int sock);
    4642
    4743CF_EXPORT int
    48 CF_Socket_SetOption     (const int      sock,
    49                         const int      optname,
    50                         const void     * optval,
    51                         const size_t   optlen);
     44CF_Socket_SetOption         (const int      sock,
     45                            const int      optname,
     46                            const void     * optval,
     47                            const size_t   optlen);
    5248
    5349CF_EXPORT int
    54 CF_Socket_GetOption     (const int  sock,
    55                         const int  optname,
    56                         void       * optval,
    57                         size_t     * optlen);
     50CF_Socket_GetOption         (const int  sock,
     51                            const int  optname,
     52                            void       * optval,
     53                            size_t     * optlen);
    5854
    5955CF_EXPORT int
    60 CF_Socket_SetTimeout    (const int  sock,
    61                          const int  timeout);
     56CF_Socket_Connect           (const char             * ip,
     57                             const unsigned short   port);
    6258
    6359CF_EXPORT int
    64 CF_Socket_Connect       (const char             * ip,
    65                          const unsigned short   port);
     60CF_Socket_ConnectTimeout    (const char             * ip,
     61                             const unsigned short   port,
     62                             const int              timeout);
    6663
    6764CF_EXPORT int
    68 CF_Socket_Server        (const unsigned short   port,
    69                         const int              backlog);
     65CF_Socket_Server            (const unsigned short   port,
     66                            const int              backlog);
    7067
    7168CF_EXPORT int
    72 CF_Socket_Accept        (const int          sock,
    73                          struct sockaddr_in * address);
     69CF_Socket_Accept            (const int          sock,
     70                             CF_Socket_HostInfo * host);
    7471
    7572CF_EXPORT int
    76 CF_Socket_Send          (const int  sock,
    77                         const void * buf,
    78                         const int  len);
     73CF_Socket_Send              (const int  sock,
     74                            const void * buf,
     75                            const int  len);
    7976
    8077CF_EXPORT int
    81 CF_Socket_Recv          (const int  sock,
    82                          void       * buf,
    83                          const int  len);
     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);
    8493
    8594#ifdef __cplusplus
Note: See TracChangeset for help on using the changeset viewer.