Skip to content

PlayerLink::Core::TCPSocket

More...

#include <tcpsocket.h>

Inherits from Socket

Public Functions

Name
TCPSocket(int fd)
TCPSocket()
bool connect(std::string address, std::string port)
Connects to an address and port.
bool connectWithTimeout(std::string address, std::string port, int seconds =TIMEOUT_SECONDS, int microseconds =TIMEOUT_MICROSECONDS)
Connects to an address and port with a timeout.
bool canReceive(int timeout =10000)
Checks if the remote machine can recieve.
size_t recieve(void * buffer, size_t bufferLength)
size_t recieveAll(void * buffer, size_t bufferLength)
unsigned char * recieveBytes()
Recieves bytes from the remote.
bool setRecvTimeout(int seconds =TIMEOUT_SECONDS, int microseconds =TIMEOUT_MICROSECONDS)
size_t send(void const * buffer, size_t bufferLength)
size_t sendAll(void const * buffer, size_t bufferLength)
bool sendBytes(unsigned char * message)
Sends bytes to remote.
bool setSendTimeout(int seconds =TIMEOUT_SECONDS, int microseconds =TIMEOUT_MICROSECONDS)

Additional inherited members

Public Functions inherited from Socket

Name
Socket(int family, int type, int flag)
Constructs a Socket object.
Socket(int fd)
std::string getAddress() const
Returns the IP Address of the remote device.
uint32_t getPort() const
int getSocketDescriptor() const
bool close()
Closes the connection.
bool isClosed()
bool setBlocking(bool swtch)
Allows you to set the blocking mode for this file descriptor.
int getLastError()

Protected Attributes inherited from Socket

Name
int mSocketFD
File Descriptor for this socket instance.
bool socketIsClosed
Flag if socket is open or closed.
bool isBlocked
Boolean to determine if blocking is enabled on this socket instance.

Detailed Description

class PlayerLink::Core::TCPSocket;

TCPSocket Class extends the base socket class

Public Functions Documentation

function TCPSocket

explicit TCPSocket(
    int fd
)

function TCPSocket

explicit TCPSocket()

function connect

bool connect(
    std::string address,
    std::string port
)

Connects to an address and port.

Parameters:

  • address The destination address
  • port The destination port

Return: True if connection was successful and false if there was a problem

function connectWithTimeout

bool connectWithTimeout(
    std::string address,
    std::string port,
    int seconds =TIMEOUT_SECONDS,
    int microseconds =TIMEOUT_MICROSECONDS
)

Connects to an address and port with a timeout.

Parameters:

  • address The destination address
  • port The destination port
  • seconds The number of seconds to wait for a reply
  • microseconds The number of microseconds to wait for a reply

Return: True if connection was successful and false if there was a problem

function canReceive

bool canReceive(
    int timeout =10000
)

Checks if the remote machine can recieve.

Parameters:

  • timeout The number of microseconds to wait before returning false

Return: True if remote is able to recieve packets and false if it can't or does not respond

function recieve

size_t recieve(
    void * buffer,
    size_t bufferLength
)

function recieveAll

size_t recieveAll(
    void * buffer,
    size_t bufferLength
)

function recieveBytes

unsigned char * recieveBytes()

Recieves bytes from the remote.

Return: an char* type used to hold incoming bytes

function setRecvTimeout

bool setRecvTimeout(
    int seconds =TIMEOUT_SECONDS,
    int microseconds =TIMEOUT_MICROSECONDS
)

function send

size_t send(
    void const * buffer,
    size_t bufferLength
)

function sendAll

size_t sendAll(
    void const * buffer,
    size_t bufferLength
)

function sendBytes

bool sendBytes(
    unsigned char * message
)

Sends bytes to remote.

Parameters:

  • message The bytes in a unsigned char*

Return: True if message was recieved successfully

function setSendTimeout

bool setSendTimeout(
    int seconds =TIMEOUT_SECONDS,
    int microseconds =TIMEOUT_MICROSECONDS
)

Updated on 20 January 2021 at 18:58:22 UTC