Class TcpSocket
Defined in File TcpSocket.h
Inheritance Relationships
Base Type
public visionary::ITransport
(Class ITransport)
Class Documentation
-
class TcpSocket : public visionary::ITransport
Public Functions
-
int connect(const std::string &hostname, uint16_t port)
-
int openServer(uint16_t port)
-
int openTcp(uint16_t port)
-
bool WaitForConnection()
-
int shutdown()
-
virtual int send(const std::vector<std::uint8_t> &buffer) override
Send data on socket to device
All bytes are sent on the socket. It is regarded as error if this is not possible.
- Parameters:
buffer – [in] buffer containing the bytes that shall be sent.
- Returns:
OS error code.
-
virtual int recv(std::vector<std::uint8_t> &buffer, std::size_t maxBytesToReceive) override
Receive data on socket to device
Receive at most maxBytesToReceive bytes.
- Parameters:
buffer – [in] buffer containing the bytes that shall be sent.
maxBytesToReceive – [in] maximum number of bytes to receive.
- Returns:
number of received bytes, negative values are OS error codes.
-
virtual int read(std::vector<std::uint8_t> &buffer, std::size_t nBytesToReceive) override
Read a number of bytes
Contrary to recv this method reads precisely nBytesToReceive bytes.
- Parameters:
buffer – [in] buffer containing the bytes that shall be sent.
maxBytesToReceive – [in] maximum number of bytes to receive.
- Returns:
number of received bytes, negative values are OS error codes.
-
int connect(const std::string &hostname, uint16_t port)