9#ifndef CClientTCPSocket_H
10#define CClientTCPSocket_H
22 class CServerTCPSocket;
47# if MRPT_WORD_SIZE==64
87 const std::string &remotePartAddress,
88 unsigned short remotePartTCPPort,
89 unsigned int timeout_ms = 0 );
138 const int timeoutStart_ms = -1,
139 const int timeoutBetween_ms = -1);
152 const int timeout_ms = -1 );
161 const int timeout_ms = -1
172 const unsigned int timeoutStart_ms = 100,
173 const unsigned int timeoutBetween_ms = 1000
A TCP socket that can be connected to a TCP server, implementing MRPT's CStream interface for passing...
bool sendMessage(const CMessage &outMsg, const int timeout_ms=-1)
Send a message through the TCP stream.
uint64_t getTotalBytesCount() MRPT_OVERRIDE
This virtual method has no effect in this implementation over a TCP socket, and its use raises an exc...
uint64_t Seek(uint64_t Offset, CStream::TSeekOrigin Origin=sFromBeginning) MRPT_OVERRIDE
This virtual method has no effect in this implementation over a TCP socket, and its use raises an exc...
std::string m_remotePartIP
The IP address of the remote part of the connection.
int getSOSendBufffer()
Return the current size of the SO send buffer.
size_t writeAsync(const void *Buffer, const size_t Count, const int timeout_ms=-1)
A method for writing to the socket with optional timeouts.
CClientTCPSocket()
Default constructor.
int setTCPNoDelay(const int &newValue)
Set the TCP no delay option of the protocol (Nagle algorithm).
int m_hSock
The handle for the connected TCP socket, or -1.
void close()
Closes the connection.
int getTCPNoDelay()
Return the value of the TCPNoDelay option.
uint64_t getPosition() MRPT_OVERRIDE
This virtual method has no effect in this implementation over a TCP socket, and its use raises an exc...
size_t getReadPendingBytes()
Return the number of bytes already in the receive queue (they can be read without waiting)
void connect(const std::string &remotePartAddress, unsigned short remotePartTCPPort, unsigned int timeout_ms=0)
Establishes a connection with a remote part.
void sendString(const std::string &str)
Writes a string to the socket.
std::string getLastErrorStr()
Returns a description of the last Sockets error.
bool isConnected()
Returns true if this objects represents a successfully connected socket.
static unsigned int DNS_LOOKUP_TIMEOUT_MS
See description of CClientTCPSocket.
size_t Write(const void *Buffer, size_t Count) MRPT_OVERRIDE
Introduces a virtual method responsible for writing to the stream.
int setSOSendBufffer(const int &newValue)
Set the size of the SO send buffer.
~CClientTCPSocket()
Destructor.
size_t Read(void *Buffer, size_t Count) MRPT_OVERRIDE
Introduces a virtual method responsible for reading from the stream (This method BLOCKS) This method ...
size_t readAsync(void *Buffer, const size_t Count, const int timeoutStart_ms=-1, const int timeoutBetween_ms=-1)
A method for reading from the socket with an optional timeout.
bool receiveMessage(CMessage &inMsg, const unsigned int timeoutStart_ms=100, const unsigned int timeoutBetween_ms=1000)
Waits for an incoming message through the TCP stream.
unsigned short m_remotePartPort
The TCP port of the remote part of the connection.
A class that contain generic messages, that can be sent and received from a "CClientTCPSocket" object...
A TCP socket that can be wait for client connections to enter.
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
TSeekOrigin
Used in CStream::Seek.
std::string BASE_IMPEXP getLastSocketErrorStr()
Returns a description of the last Sockets error.
#define MRPT_OVERRIDE
C++11 "override" for virtuals:
#define THROW_EXCEPTION(msg)
#define MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.