Changeset 14 in cheroxy for trunk/include


Ignore:
Timestamp:
10/24/12 11:12:11 (12 years ago)
Author:
cheese
Message:

#1 add timeout to socket connection and fix test label in makefile

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/CRXSocket.h

    r5 r14  
    1818using namespace std;
    1919
    20 typedef struct sockaddr     stSockAddr;
    21 typedef struct sockaddr_in  stSockAddrIn;
    22 typedef unsigned short      ushort;
    23 typedef unsigned int        uint;
     20#define TCPSOCKET_NO_TIMEOUT                    -1
    2421
    2522#define ERROR_TCPSOCKET                         -1000
     
    3633#define ERROR_TCPSOCKET_FAILED_TO_RECEIVE       ERROR_TCPSOCKET - 10
    3734#define ERROR_TCPSOCKET_NOT_READY               ERROR_TCPSOCKET - 11
     35#define ERROR_TCPSOCKET_FAILED_TO_SETSOCKOPT    ERROR_TCPSOCKET - 12
    3836
    3937class CRXSocket
    4038{
    4139private:
    42     static bool     mInitialized;
    43     stSockAddrIn    mAddress;
    44     int             mSocket;
     40    static bool         mInitialized;
     41    struct sockaddr_in  mAddress;
     42    int                 mSocket;
    4543
    4644private:
     
    9088     * for server
    9189     */
    92     int CreateServer            (ushort         aPort,
    93                                  int            aBacklog = 5,
    94                                  stSockAddrIn   * aAddress = NULL);
     90    int CreateServer            (const unsigned short   aPort,
     91                                 const int              aBacklog = 5,
     92                                 struct sockaddr_in     * aAddress = NULL);
    9593
    96     int Accept                  (stSockAddrIn   * aRemoteAddress = NULL,
    97                                  int            * aAddressLength = NULL);
     94    int Accept                  (struct sockaddr_in * aRemoteAddress = NULL,
     95                                 int                * aAddressLength = NULL);
    9896
    9997    /**
    10098     * for client
    10199     */
    102     int Connect                 (std::string    aUrl,
    103                                  ushort         aPort);
     100    int Connect                 (const std::string      aUrl,
     101                                 const unsigned short   aPort,
     102                                 const int              aTimeout = TCPSOCKET_NO_TIMEOUT);
    104103
    105104    /**
Note: See TracChangeset for help on using the changeset viewer.