Skip to content

PlayerLink::Core::Socket

Lowest socket implementation. This class will be used by top level socket implementations. More...

#include <Socket.h>

Inherited by TCPSocket, TCPServer

Public Functions

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

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::Socket;

Lowest socket implementation. This class will be used by top level socket implementations.

Author: Hanzalah Ravat

Public Functions Documentation

function Socket

Socket(
    int family,
    int type,
    int flag
)

Constructs a Socket object.

Parameters:

  • family Address Family.
  • type The type specification for the new socket
  • flag The protocol used for data transmission

Return: If no error occurs, socket returns a descriptor referencing the new socket. Otherwise, a value of -1

Attention: Winsock2.dll is automatically initialised when using this method on a Windows Device

function Socket

explicit Socket(
    int fd
)

function getAddress

std::string getAddress() const

Returns the IP Address of the remote device.

Return: Gets the address of the remote device

function getPort

uint32_t getPort() const

Return: The port number used for this connection

function getSocketDescriptor

int getSocketDescriptor() const

Return: The socket descriptor used for this socket

function close

bool close()

Closes the connection.

Return: True if socket closes or false if there was an error while closing the socket

function isClosed

bool isClosed()

Return: true if the socket connection has been closed or false if it is still open

function setBlocking

bool setBlocking(
    bool swtch
)

Allows you to set the blocking mode for this file descriptor.

Parameters:

  • swtch Sets the blocking value

Return: The result of the blocking, True if blocking was successful or false if there was an issue with changing the blocking status

function getLastError

int getLastError()

Return: The last error number

Protected Attributes Documentation

variable mSocketFD

int mSocketFD;

File Descriptor for this socket instance.

variable socketIsClosed

bool socketIsClosed;

Flag if socket is open or closed.

variable isBlocked

bool isBlocked;

Boolean to determine if blocking is enabled on this socket instance.


Updated on 26 January 2021 at 14:33:10 UTC