Hazelcast C++ Client
 All Classes Functions Variables Enumerations Enumerator Pages
Public Member Functions | List of all members
hazelcast::client::Socket Class Reference

c Sockets wrapper class. More...

#include <Socket.h>

Public Member Functions

 Socket (int socketId)
 Constructor.
 
 Socket (const client::Address &address)
 Constructor.
 
virtual ~Socket ()
 Destructor.
 
int connect (int timeoutInMillis)
 connects to given address in constructor. More...
 
virtual int send (const void *buffer, int len) const
 
int receive (void *buffer, int len, int flag=0) const
 
int getSocketId () const
 return socketId
 
void setRemoteEndpoint (const client::Address &address)
 
const client::AddressgetRemoteEndpoint () const
 
void close ()
 closes the socket. More...
 
client::Address getAddress () const
 
void setBlocking (bool blocking)
 

Detailed Description

c Sockets wrapper class.

Member Function Documentation

void hazelcast::client::Socket::close ( )

closes the socket.

Automatically called in destructor. Second call to this function is no op.

int hazelcast::client::Socket::connect ( int  timeoutInMillis)

connects to given address in constructor.

Parameters
timeoutInMillisif not connected within timeout, it will return errorCode
Returns
zero if error. -1 otherwise.
const client::Address & hazelcast::client::Socket::getRemoteEndpoint ( ) const
Returns
remoteEndpoint
int hazelcast::client::Socket::receive ( void *  buffer,
int  len,
int  flag = 0 
) const
Parameters
buffer
lenlength of the buffer to be received.
flagbsd sockets options flag.
Returns
number of bytes received.
Exceptions
IOExceptionin failure.
int hazelcast::client::Socket::send ( const void *  buffer,
int  len 
) const
virtual
Parameters
buffer
lenlength of the buffer
Returns
number of bytes send
Exceptions
IOExceptionin failure.

In linux, sometimes SIGBUS may be received during this call when the server closes the connection. The returned error code is still error when this flag is set. Hence, it is safe to use. MSG_NOSIGNAL (since Linux 2.2) Requests not to send SIGPIPE on errors on stream oriented sockets when the other end breaks the connection. The EPIPE error is still returned.

void hazelcast::client::Socket::setRemoteEndpoint ( const client::Address address)
Parameters
addressremote endpoint address.

The documentation for this class was generated from the following files: