![]() |
Murl Engine API
Version 2018.3
|
The socket interface. More...
#include <murl_net_i_socket.h>
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.
Inherited by Murl::Net::Socket.
Public Types | |
typedef SharedPointer< ISocket > | SharedPtr |
Definition of the socket shared pointer. | |
typedef Array< SharedPtr > | PtrArray |
Definition of the socket shared pointer array. | |
Public Member Functions | |
virtual void | SetName (const String &name)=0 |
Set the name of the socket. More... | |
virtual const String & | GetName () const =0 |
Get the name of the socket. More... | |
virtual void | SetUniqueIdentifier (const String &uniqueId)=0 |
Set the unique identifier of the socket. More... | |
virtual const String & | GetUniqueIdentifier () const =0 |
Get the unique identifier of the socket. More... | |
virtual Bool | ConnectTcp (ISocketAddressPtr address)=0 |
Connects to a specified server address using tcp. More... | |
virtual Bool | ConnectTcpNonBlocking (ISocketAddressPtr address)=0 |
Connects to a specified server address using tcp with non blocking. More... | |
virtual Bool | ConfirmConnectTcpNonBlocking ()=0 |
Confirm connect using tcp with non blocking. More... | |
virtual Bool | ConnectUdp (ISocketAddressPtr address)=0 |
Connects to a specified server address using udp. More... | |
virtual Bool | BindTcpListen (ISocketAddressPtr address, UInt32 maxQueue=5)=0 |
Bind a listener to accept tcp connections. More... | |
virtual Bool | BindUdpListen (ISocketAddressPtr address)=0 |
Bind a listener to accept udp connections. More... | |
virtual Bool | CreateUdpBroadcast ()=0 |
Create a socket to send udp broadcast. More... | |
virtual Bool | Disconnect ()=0 |
Disconnect the socket. More... | |
virtual Bool | IsConnected () const =0 |
Check if the socket is connected. More... | |
virtual Bool | IsConnecting () const =0 |
Check if the socket is connecting in non blocking mode. More... | |
virtual Bool | Accept (ISocket::SharedPtr listenSocket)=0 |
Accept connection on the socket. More... | |
virtual Bool | AcceptNonBlocking (ISocket::SharedPtr listenSocket)=0 |
Accept connection on the socket. More... | |
virtual Bool | Pair (ISocket::SharedPtr pairSocket)=0 |
Create a socket pair ready to communicate. More... | |
virtual SInt32 | Select (PtrArray &readSockets, PtrArray &writeSockets, Double timeout)=0 |
Wait for ready to read and write sockets with timeout. More... | |
virtual Bool | IsReadSelected () const =0 |
Check if the socket was read selected during the last Select(). More... | |
virtual Bool | IsWriteSelected () const =0 |
Check if the socket was write selected during the last Select(). More... | |
virtual Bool | Receive (Data &data)=0 |
Receive data from the socket. More... | |
virtual Bool | Send (const ConstData &data)=0 |
Send the entire data to the socket. More... | |
virtual SInt64 | Send (const ConstData &data, UInt64 byteOffset)=0 |
Send data form a specified offset to the socket. More... | |
virtual Bool | ReceiveFrom (Data &data, ISocketAddressPtr address)=0 |
Receive data and the sender address from the socket. More... | |
virtual Bool | SendTo (const ConstData &data, ISocketAddressPtr address)=0 |
Send the entire data to a specified address. More... | |
virtual SInt64 | SendTo (const ConstData &data, UInt64 byteOffset, ISocketAddressPtr address)=0 |
Send data form a specified offset to a specified address. More... | |
virtual System::Socket & | GetSystemSocket ()=0 |
Get the system socket object. More... | |
virtual const System::Socket & | GetSystemSocket () const =0 |
Get the const system socket object. More... | |
|
pure virtual |
Set the name of the socket.
name | The name of the socket. |
|
pure virtual |
Get the name of the socket.
|
pure virtual |
Set the unique identifier of the socket.
uniqueId | The unique identifier of the socket. |
|
pure virtual |
Get the unique identifier of the socket.
|
pure virtual |
Connects to a specified server address using tcp.
Enables reuse-address, keep-alive and tcp-no-delay socket option.
address | The address of the server to connect. |
|
pure virtual |
Connects to a specified server address using tcp with non blocking.
Enables reuse-address, keep-alive, tcp-no-delay and non-blocking socket option.
address | The address of the server to connect. |
|
pure virtual |
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.
|
pure virtual |
Connects to a specified server address using udp.
Enables tcp-no-delay socket option.
address | The address of the server to connect. |
|
pure virtual |
Bind a listener to accept tcp connections.
Enables reuse-address and keep-alive socket option.
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. |
|
pure virtual |
Bind a listener to accept udp connections.
Enables reuse-address socket option.
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). |
|
pure virtual |
Create a socket to send udp broadcast.
Enables reuse-address and broadcast socket option.
|
pure virtual |
Disconnect the socket.
|
pure virtual |
Check if the socket is connected.
|
pure virtual |
Check if the socket is connecting in non blocking mode.
|
pure virtual |
Accept connection on the socket.
Enables keep-alive and tcp-no-delay socket option after accept.
listenSocket | The socket which is listening for the connection. |
|
pure virtual |
Accept connection on the socket.
Enables keep-alive, tcp-no-delay and non-blocking socket option after accept.
listenSocket | The socket which is listening for the connection. |
|
pure virtual |
Create a socket pair ready to communicate.
pairSocket | The socket to connect with this socket. |
|
pure virtual |
Wait for ready to read and write sockets with 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. |
|
pure virtual |
|
pure virtual |
Receive data from the socket.
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.
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.
data | The data to send. |
byteOffset | The data offset in number of bytes. |
|
pure virtual |
Receive data and the sender address from the socket.
This is typically used by sockets connected with ConnectUdpListen().
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. |
|
pure virtual |
Send the entire data to a specified address.
This is typically used by sockets connected with ConnectUdpBroadcast().
data | The data to send. |
address | The address to send the data. |
|
pure virtual |
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.
data | The data to send. |
byteOffset | The data offset in number of bytes. |
address | The address to send the data. |
|
pure virtual |
Get the system socket object.
|
pure virtual |
Get the const system socket object.