Socket

The socket interface allows you to create a server or a client using either the TCP/IP or UDP protocol. Using sockets you can transfer data between two devices either on a local network or via the internet. You can use this approach to send or download file, create a game server, provide audio or text chat for your application and a lot more.

Static Variables


Name Description
ip IP address, only available upon connection.
recv_buffer_size Current size of the receive buffer.
protocol Represent the current protocol use by the Socket.

Variables


Name Description
sck_id Unique socket id given by the system.

Functions


Name Description
Create Create a new non-blocking socket.
Destroy Destroy a previously initialized Socket.
GenId Generate a new Socket id ready for transmission.
Bind Bind the socket start listening (TCP only) on the port specified.
Accept Accep a new Socket connection.
Connect Function to establish a connection with a local or remove port.
Close Close the active socket connection.
SetOption Set a specific SocketOption value.
Recv Function to check if data have been received by the Socket.
GetRecvBuffer Set a specific SocketOption value.
Send Send data over the Socket connection.

SocketOption


Constant value to use an option which can be set via the SetOption function of the Socket interface.

  • kNonBlock: Enable or disable non-blocking socket.
  • kTcpNoDelay: Control the availability of the "Nagle" algorithm.
  • kSendBufferSize: Allows you to specify the size of the send buffer.
  • kRecvBufferSize: Allows you to change the size of the receive buffer.
  • kReuseAddress: This option allows multiple sockets to be open on the same port. If using UDP, it is used for broadcast.




NRG - API 2022.4.384543 - Fri Nov 4 2022
Copyright © 2022 nrgcore.com. All Rights Reserved. Terms of Service - Privacy Policy - EULA