Hazelcast C++ Client
Public Member Functions | List of all members
hazelcast::client::internal::socket::TcpSocket Class Reference

c Sockets wrapper class. More...

#include <TcpSocket.h>

+ Inheritance diagram for hazelcast::client::internal::socket::TcpSocket:

Public Member Functions

 TcpSocket (int socketId)
 Constructor.
 
 TcpSocket (const client::Address &address)
 Constructor.
 
virtual ~TcpSocket ()
 Destructor.
 
int connect (int timeoutInMillis)
 connects to given address in constructor. More...
 
int send (const void *buffer, int len, int flag=0)
 
int receive (void *buffer, int len, int flag=0)
 
int getSocketId () const
 return socketId
 
void close ()
 closes the socket. More...
 
Address getAddress () const
 
void setBlocking (bool blocking)
 
std::auto_ptr< AddresslocalSocketAddress () const
 This function is used to obtain the locally bound endpoint of the socket. More...
 
- Public Member Functions inherited from hazelcast::client::Socket
virtual ~Socket ()
 Destructor.
 

Detailed Description

c Sockets wrapper class.

Member Function Documentation

◆ close()

void hazelcast::client::internal::socket::TcpSocket::close ( )
virtual

closes the socket.

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

Implements hazelcast::client::Socket.

◆ connect()

int hazelcast::client::internal::socket::TcpSocket::connect ( int  timeoutInMillis)
virtual

connects to given address in constructor.

Parameters
timeoutInMillisif not connected within timeout, it will return errorCode
Returns
zero if error. -1 otherwise.

Implements hazelcast::client::Socket.

◆ localSocketAddress()

std::auto_ptr< Address > hazelcast::client::internal::socket::TcpSocket::localSocketAddress ( ) const
virtual

This function is used to obtain the locally bound endpoint of the socket.

Returns
An address that represents the local endpoint of the socket.

Implements hazelcast::client::Socket.

◆ receive()

int hazelcast::client::internal::socket::TcpSocket::receive ( void *  buffer,
int  len,
int  flag = 0 
)
virtual
Parameters
buffer
lenlength of the buffer to be received.
flagbsd sockets options flag.
Returns
number of bytes received.
Exceptions
IOExceptionin failure.

Implements hazelcast::client::Socket.

◆ send()

int hazelcast::client::internal::socket::TcpSocket::send ( const void *  buffer,
int  len,
int  flag = 0 
)
virtual
Parameters
buffer
lenlength of the buffer
flagbsd sockets options flag.
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.

Implements hazelcast::client::Socket.


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