libcmutils 0.6.5
Multi-platform C99 utility library
Loading...
Searching...
No Matches

Socket object. More...

Data Fields

CMSocketResult(* Read )(const CMUTIL_Socket *socket, CMUTIL_ByteBuffer *buffer, uint32_t size, long timeout)
 Read data from the socket into a buffer.
 
CMSocketResult(* Write )(const CMUTIL_Socket *socket, const void *data, uint32_t size, long timeout)
 Write the given data to the socket into a buffer.
 
CMSocketResult(* WritePart )(const CMUTIL_Socket *socket, const void *data, uint32_t offset, uint32_t length, long timeout)
 Write a specific part of data to the socket from a buffer.
 
CMSocketResult(* CheckReadBuffer )(const CMUTIL_Socket *socket, long timeout)
 Check if the socket is ready for reading.
 
CMSocketResult(* CheckWriteBuffer )(const CMUTIL_Socket *socket, long timeout)
 Check if the socket is ready for writing.
 
CMUTIL_Socket *(* ReadSocket )(const CMUTIL_Socket *socket, long timeout, CMSocketResult *rval)
 Read a socket object from the current socket.
 
CMSocketResult(* WriteSocket )(const CMUTIL_Socket *socket, CMUTIL_Socket *tobesent, pid_t pid, long timeout)
 Write a socket object to the current socket.
 
CMSocketResult(* GetRemoteAddr )(const CMUTIL_Socket *socket, CMUTIL_SocketAddr *addr)
 Get the remote address of the socket.
 
void(* Close )(CMUTIL_Socket *socket)
 Close the socket.
 
SOCKET(* GetRawSocket )(const CMUTIL_Socket *socket)
 Get the raw socket descriptor.
 
int(* ReadByte )(const CMUTIL_Socket *socket, long timeout)
 Read a single byte from the socket.
 
CMSocketResult(* WriteByte )(const CMUTIL_Socket *socket, uint8_t c, long timeout)
 Write a single byte to the socket.
 
void(* SetSilent )(CMUTIL_Socket *socket, CMBool silent)
 Suppress this library's own error logging on this socket.
 

Detailed Description

Socket object.

Field Documentation

◆ Read

CMSocketResult(* CMUTIL_Socket::Read) (const CMUTIL_Socket *socket, CMUTIL_ByteBuffer *buffer, uint32_t size, long timeout)

Read data from the socket into a buffer.

Reads up to 'size' bytes of data from the specified socket into the provided byte buffer within the given timeout period.

Parameters
socketThe socket object to read from.
bufferThe byte buffer to store the read data.
sizeThe maximum number of bytes to read.
timeoutThe read operation timeout in milliseconds.
Returns
CMSocketResult indicating success or failure.

◆ Write

CMSocketResult(* CMUTIL_Socket::Write) (const CMUTIL_Socket *socket, const void *data, uint32_t size, long timeout)

Write the given data to the socket into a buffer.

Writes all data from the provided byte buffer to the specified socket within the specified timeout period.

Parameters
socketThe socket object to write to.
dataThe data to write.
sizeThe size of the data to write.
timeoutThe read operation timeout in milliseconds.
Returns
CMSocketResult indicating success or failure.

◆ WritePart

CMSocketResult(* CMUTIL_Socket::WritePart) (const CMUTIL_Socket *socket, const void *data, uint32_t offset, uint32_t length, long timeout)

Write a specific part of data to the socket from a buffer.

Writes 'length' bytes of data from the provided string buffer starting at the given offset to the specified socket within the specified timeout period.

Parameters
socketThe socket object to write to.
dataThe data to write.
offsetThe offset in the buffer to start writing from.
lengthThe number of bytes to write.
timeoutThe write operation timeout in milliseconds.
Returns
CMSocketResult indicating success or failure.

◆ CheckReadBuffer

CMSocketResult(* CMUTIL_Socket::CheckReadBuffer) (const CMUTIL_Socket *socket, long timeout)

Check if the socket is ready for reading.

This function checks if there is data available to read from the socket within the specified timeout period.

Parameters
socketThe socket object to check.
timeoutThe timeout period in milliseconds.
Returns
CMSocketResult indicating if the socket is ready for reading.

◆ CheckWriteBuffer

CMSocketResult(* CMUTIL_Socket::CheckWriteBuffer) (const CMUTIL_Socket *socket, long timeout)

Check if the socket is ready for writing.

This function checks if the socket is ready to accept data for writing within the specified timeout period.

Parameters
socketThe socket object to check.
timeoutThe timeout period in milliseconds.
Returns
CMSocketResult indicating if the socket is ready for writing.

◆ ReadSocket

CMUTIL_Socket *(* CMUTIL_Socket::ReadSocket) (const CMUTIL_Socket *socket, long timeout, CMSocketResult *rval)

Read a socket object from the current socket.

This function reads a new socket object from the current socket within the specified timeout period.

Parameters
socketThe socket object to read from.
timeoutThe read operation timeout in milliseconds.
rvalPointer to store the result of the read operation.
Returns
A new CMUTIL_Socket object if successful, NULL otherwise.

◆ WriteSocket

CMSocketResult(* CMUTIL_Socket::WriteSocket) (const CMUTIL_Socket *socket, CMUTIL_Socket *tobesent, pid_t pid, long timeout)

Write a socket object to the current socket.

This function writes the specified socket object to the current socket within the specified timeout period.

Parameters
socketThe socket object to write to.
tobesentThe socket object to be sent.
pidThe process ID associated with the socket.
timeoutThe write operation timeout in milliseconds.
Returns
CMSocketResult indicating success or failure.

◆ GetRemoteAddr

CMSocketResult(* CMUTIL_Socket::GetRemoteAddr) (const CMUTIL_Socket *socket, CMUTIL_SocketAddr *addr)

Get the remote address of the socket.

This function retrieves the remote address of the specified socket and stores it in the provided socket address object.

Parameters
socketThe socket object to get the remote address from.
addrPointer to the CMUTIL_SocketAddr object to store the address.
Returns
CMSocketResult indicating success or failure.

◆ Close

void(* CMUTIL_Socket::Close) (CMUTIL_Socket *socket)

Close the socket.

This function closes the specified socket and releases any associated resources.

Parameters
socketThe socket object to be closed.

◆ GetRawSocket

SOCKET(* CMUTIL_Socket::GetRawSocket) (const CMUTIL_Socket *socket)

Get the raw socket descriptor.

This function retrieves the underlying raw socket descriptor associated with the specified socket object.

Parameters
socketThe socket object to get the raw socket from.
Returns
The raw socket descriptor.

◆ ReadByte

int(* CMUTIL_Socket::ReadByte) (const CMUTIL_Socket *socket, long timeout)

Read a single byte from the socket.

This function reads a single byte from the specified socket.

Parameters
socketThe socket object to read from.
timeoutTimeout in milliseconds for the read operation.
Returns
The byte read from the socket, or -1 on failure.

◆ WriteByte

CMSocketResult(* CMUTIL_Socket::WriteByte) (const CMUTIL_Socket *socket, uint8_t c, long timeout)

Write a single byte to the socket.

This function writes a single byte to the specified socket.

Parameters
socketThe socket object to write to.
cThe byte to be written.
timeoutTimeout in milliseconds for the write operation.
Returns
CMSocketResult indicating success or failure.

◆ SetSilent

void(* CMUTIL_Socket::SetSilent) (CMUTIL_Socket *socket, CMBool silent)

Suppress this library's own error logging on this socket.

A disconnect a server expects - a client that simply went away - is not worth an error line. Turning this on demotes those messages to trace level; the return codes are unaffected.

Parameters
socketThe socket object.
silentCMTrue to stop logging errors for this socket.

The documentation for this struct was generated from the following file: