
Public Member Functions | |
| ServerSocket () | |
| constructor | |
| ~ServerSocket () | |
| destructor | |
| bool | Connect (unsigned long a_nIpAddress, int a_nPort, int a_nTimeout) |
| connect the socket to an address | |
| bool | IsConnected () const |
| Determine if we are currently connected to a server. | |
| void | Disconnect () |
| Disconnect from the server. | |
| void | SendBytes (const char *a_pszBuf, size_t a_nBufSiz) |
| Send the supplied bytes to the server. | |
| int | GetBytes (char *a_pszBuf, int a_nBufSiz) |
| Receive a block of data from the server. | |
| void | DiscardBytes (int a_nBytes) |
| Receive and discard bytes. | |
| char | GetByte () |
| Receive a single byte. | |
Private Member Functions | |
| ServerSocket (const ServerSocket &) | |
| copy constructor is disabled | |
| ServerSocket & | operator= (const ServerSocket &) |
| copy operator is disabled | |
| int | ReceiveBytes (char *a_pszBuf, int a_nBufSiz) |
| Receive data into a buffer with as many bytes as possible up to the size of the buffer. | |
Private Attributes | |
| SOCKET | mSocket |
| socket being abstracted | |
| char | mBuf [MAXBUF] |
| internal data buffer | |
| int | mIdx |
| current read index for mBuf | |
| int | mBufLen |
| current end index for mBuf | |
Static Private Attributes | |
| static const int | MAXBUF = 1024 |
| size of internal data buffer | |
Classes | |
| class | Exception |
| Exception thrown on any send or receive error. More... | |
Definition at line 61 of file MemCacheClient.cpp.
| int ServerSocket::ReceiveBytes | ( | char * | a_pszBuf, | |
| int | a_nBufSiz | |||
| ) | [private] |
Receive data into a buffer with as many bytes as possible up to the size of the buffer.
| a_pszBuf | Buffer to be filled | |
| a_nBufSiz | Maximum number of bytes to receive |
Definition at line 268 of file MemCacheClient.cpp.
References Disconnect(), and mSocket.
Referenced by DiscardBytes(), GetByte(), and GetBytes().
| bool ServerSocket::Connect | ( | unsigned long | a_nIpAddress, | |
| int | a_nPort, | |||
| int | a_nTimeout | |||
| ) |
connect the socket to an address
| a_nIpAddress | Server IP address as returned from inet_addr | |
| a_nPort | Server port | |
| a_nTimeout | Connection timeout period in milliseconds |
Definition at line 193 of file MemCacheClient.cpp.
References Disconnect(), and mSocket.
Referenced by MemCacheClient::Server::Connect().
| void ServerSocket::SendBytes | ( | const char * | a_pszBuf, | |
| size_t | a_nBufSiz | |||
| ) |
Send the supplied bytes to the server.
A blocking send is used, so the function will block until either all bytes are sent or an error occurs.
| a_pszBuf | Bytes to send to the server | |
| a_nBufSiz | Number of bytes to send to the server |
| Exception | on socket error |
Definition at line 252 of file MemCacheClient.cpp.
References Disconnect(), and mSocket.
Referenced by MemCacheClient::Combine(), MemCacheClient::FlushAll(), MemCacheClient::IncDec(), and MemCacheClient::Store().
| int ServerSocket::GetBytes | ( | char * | a_pszBuf, | |
| int | a_nBufSiz | |||
| ) |
Receive a block of data from the server.
| a_pszBuf | Buffer to receive the data into | |
| a_nBufSiz | Maximum number of bytes to be received |
| Exception | on socket error |
Definition at line 282 of file MemCacheClient.cpp.
References mBuf, mBufLen, mIdx, and ReceiveBytes().
Referenced by MemCacheClient::HandleGetResponse().
| void ServerSocket::DiscardBytes | ( | int | a_nBytes | ) |
Receive and discard bytes.
| a_nBytes | Number of bytes to be received and ignored. |
| Exception | on socket error |
Definition at line 299 of file MemCacheClient.cpp.
References MAXBUF, mBuf, mBufLen, mIdx, and ReceiveBytes().
Referenced by MemCacheClient::HandleGetResponse().
| char ServerSocket::GetByte | ( | ) | [inline] |
Receive a single byte.
| Exception | on socket error |
Definition at line 144 of file MemCacheClient.cpp.
References MAXBUF, mBuf, mBufLen, mIdx, and ReceiveBytes().
Referenced by MemCacheClient::FlushAll(), MemCacheClient::HandleDelResponse(), MemCacheClient::HandleGetResponse(), MemCacheClient::HandleStoreResponse(), and MemCacheClient::IncDec().
1.5.6