OnixS C++ FIX Engine 2.79.1.0
TcpClient Class Reference

Provides client connections for TCP network services.

List of all members.

Public Types

typedef std::vector< char > Bytes

Public Member Functions

 TcpClient (const std::string &hostname, int port, int timeoutInMillisecons=0)
 TcpClient ()
 ~TcpClient (void)
void connect (const std::string &hostname, int port, int timeoutInMillisecons=0)
void close ()
void setNoDelay (bool setTcpNoDelayOption=true)
bool getNoDelay () const
void send (const std::string &value)
void send (const char *buffer, size_t bufferLength)
const Bytes & receive (int timeoutInMillisecons=0)
const Bytes & receive (size_t numberOfBytesToReceive, int timeoutInMillisecons=0)

Constructor & Destructor Documentation

TcpClient ( const std::string &  hostname,
int  port,
int  timeoutInMillisecons = 0 
)

Initializes a new instance of the TcpClient class and connects to the specified port on the specified host.

Parameters:
hostnameThe DNS name of the remote host to which you intend to connect (or its IP address).
portThe port number of the remote host to which you intend to connect.
timeoutInMilliseconsTimeout value in milliseconds. If 0 then the method blocks until some data is received.

Member Function Documentation

void connect ( const std::string &  hostname,
int  port,
int  timeoutInMillisecons = 0 
)

Connects to the specified port on the specified host.

Parameters:
hostnameThe DNS name of the remote host to which you intend to connect (or its IP address).
portThe port number of the remote host to which you intend to connect.
timeoutInMilliseconsTimeout value in milliseconds. If 0 then the method blocks until some data is received.
const Bytes& receive ( size_t  numberOfBytesToReceive,
int  timeoutInMillisecons = 0 
)

Receives exactly the given number of bytes.

Parameters:
numberOfBytesToReceiveNumber of bytes to received.
timeoutInMilliseconsTimeout value in milliseconds. If 0 then the method blocks until all bytes are received.
const Bytes& receive ( int  timeoutInMillisecons = 0)

Receives the data.

Parameters:
timeoutInMilliseconsTimeout value in milliseconds. If 0 then the method blocks until some data is received.
void setNoDelay ( bool  setTcpNoDelayOption = true)

Sets a value that disables a delay when send or receive buffers are not full.

When setTcpNoDelayOption is false, a TcpClient does not send a packet over the network until it has collected a significant amount of outgoing data. Because of the amount of overhead in a TCP segment, sending small amounts of data is inefficient. However, situations do exist where you need to send very small amounts of data or expect immediate responses from each packet you send. Your decision should weigh the relative importance of network efficiency versus application requirements.