![]() |
Murl Engine Lua Addon API
Version 1.0 beta
|
The socket interface.
Several methods are blocking calls when waiting for network response.
(!) Do not use this class directly in the logic code. Use Net::ISocketClient and Net::ISocketServer interfaces instead.
Definition of the socket shared pointer.
Definition of the socket shared pointer array.
Set the name of the socket.
SetName(String name)
name | The name of the socket. |
Get the name of the socket.
String GetName()
Set the unique identifier of the socket.
SetUniqueIdentifier(String uniqueId)
uniqueId | The unique identifier of the socket. |
Get the unique identifier of the socket.
String GetUniqueIdentifier()
Connects to a specified server address using tcp. Enables reuse-address, keep-alive and tcp-no-delay socket option.
Boolean ConnectTcp(Murl.SharedPointer.NetISocketAddress address)
address | The address of the server to connect. |
Connects to a specified server address using tcp with non blocking. Enables reuse-address, keep-alive, tcp-no-delay and non-blocking socket option.
Boolean ConnectTcpNonBlocking(Murl.SharedPointer.NetISocketAddress address)
address | The address of the server to connect. |
Confirm connect using tcp with non blocking. When connection by ConnectTcpNonBlocking() a write select to the socket indicates the connection and must be confirmed by calling this method.
Boolean ConfirmConnectTcpNonBlocking()
Connects to a specified server address using udp. Enables tcp-no-delay socket option.
Boolean ConnectUdp(Murl.SharedPointer.NetISocketAddress address)
address | The address of the server to connect. |
Bind a listener to accept tcp connections. Enables reuse-address and keep-alive socket option.
Boolean BindTcpListen(Murl.SharedPointer.NetISocketAddress address, Integer maxQueue)
address | The address to listen for incoming connections. The address specifies the port to listen and the ip-address to find the correct network adapter (any-address is listening on all adapters). |
maxQueue | The maximum length of the queue of pending connections. |
Bind a listener to accept udp connections. Enables reuse-address socket option.
Boolean BindUdpListen(Murl.SharedPointer.NetISocketAddress address)
address | The address to listen for incoming connections. The address specifies the port to listen and the ip-address to find the correct network adapter (any-address is listening on all adapters). |
Create a socket to send udp broadcast. Enables reuse-address and broadcast socket option.
Boolean CreateUdpBroadcast()
Disconnect the socket.
Boolean Disconnect()
Check if the socket is connected.
Boolean IsConnected()
Check if the socket is connecting in non blocking mode.
Boolean IsConnecting()
Accept connection on the socket. Enables keep-alive and tcp-no-delay socket option after accept.
Boolean Accept(Murl.SharedPointer.NetISocket listenSocket)
listenSocket | The socket which is listening for the connection. |
Accept connection on the socket. Enables keep-alive, tcp-no-delay and non-blocking socket option after accept.
Boolean AcceptNonBlocking(Murl.SharedPointer.NetISocket listenSocket)
listenSocket | The socket which is listening for the connection. |
Create a socket pair ready to communicate.
Boolean Pair(Murl.SharedPointer.NetISocket pairSocket)
pairSocket | The socket to connect with this socket. |
Wait for ready to read and write sockets with timeout.
Integer, Murl.Array.SharedPointerNetISocket, Murl.Array.SharedPointerNetISocket Select(Murl.Array.SharedPointerNetISocket readSockets, Murl.Array.SharedPointerNetISocket writeSockets, Number timeout)
readSockets | Array of read sockets to wait for. |
writeSockets | Array of write sockets to wait for. |
timeout | The maximum time to wait in seconds, -1 for no timeout. |
Check if the socket was read selected during the last Select(). The select status is valid until the next call of Select() or the socket is closed due to errors or Destroy() is called.
Boolean IsReadSelected()
Check if the socket was write selected during the last Select(). The select status is valid until the next call of Select() or the socket is closed due to errors or Destroy() is called.
Boolean IsWriteSelected()
Receive data from the socket.
Boolean, Murl.Data Receive(Murl.Data data)
data | The data object to store the incoming data. The data object's byte size is the maximum number of bytes to receive. If the data object is empty a size of 1500 bytes is reserved internally. |
Send the entire data to the socket.
Boolean Send(Murl.ConstData data)
data | The data to send. |
Send data form a specified offset to the socket. In non-blocking operation this method sends only a portion of data and has to be called in a loop which allows to monitor the data transfer.
Integer Send(Murl.ConstData data, Integer byteOffset)
data | The data to send. |
byteOffset | The data offset in number of bytes. |
Receive data and the sender address from the socket. This is typically used by sockets connected with ConnectUdpListen().
Boolean, Murl.Data ReceiveFrom(Murl.Data data, Murl.SharedPointer.NetISocketAddress address)
data | The data object to store the incoming data. The data object's byte size is the maximum number of bytes to receive. If the data object is empty a size of 1500 bytes is reserved internally. |
address | The sender address return value. |
Send data form a specified offset to a specified address. In non-blocking operation this method sends only a portion of data and has to be called in a loop which allows to monitor the data transfer.
Integer SendTo(Murl.ConstData data, Integer byteOffset, Murl.SharedPointer.NetISocketAddress address)
data | The data to send. |
byteOffset | The data offset in number of bytes. |
address | The address to send the data. |
Send the entire data to a specified address. This is typically used by sockets connected with ConnectUdpBroadcast().
Boolean SendTo(Murl.ConstData data, Murl.SharedPointer.NetISocketAddress address)
data | The data to send. |
address | The address to send the data. |
Converts the object content to a string in a reasonable format.