diff --git a/Source/Engine/Platform/Base/NetworkBase.h b/Source/Engine/Platform/Base/NetworkBase.h index 99a93ebf5..3dff55a56 100644 --- a/Source/Engine/Platform/Base/NetworkBase.h +++ b/Source/Engine/Platform/Base/NetworkBase.h @@ -169,15 +169,87 @@ class FLAXENGINE_API NetworkBase /// The end point of the new socket. /// Return true on error. Otherwise false. static bool Accept(NetworkSocket& serverSock, NetworkSocket& newSock, NetworkEndPoint& newEndPoint); + + /// + /// Check for socket readability. + /// + /// The socket. + /// Return true when data is available. Otherwise false. static bool IsReadable(NetworkSocket& socket); + + /// + /// Check for socket writeability. + /// + /// The socket. + /// Return true when data can be written. Otherwise false. static bool IsWriteable(NetworkSocket& socket); + + /// + /// Update sockets states. + /// + /// The sockets group. + /// Return -1 on error, The number of elements where states are nonzero, otherwise 0. static int32 Poll(NetworkSocketGroup& group); + + /// + /// Retrieve socket state. + /// + /// The group. + /// The socket index in group. + /// The returned state. + /// Return true on error. Otherwise false. static bool GetSocketState(NetworkSocketGroup& group, uint32 index, NetworkSocketState& state); + + /// + /// Add a socket to a group. + /// + /// The group. + /// The socket. + /// Return the socket index in group or -1 on error. static int32 AddSocketToGroup(NetworkSocketGroup& group, NetworkSocket& socket); + + /// + /// Clear the socket group. + /// + /// The group. static void ClearGroup(NetworkSocketGroup& group); + + /// + /// Write data to the socket. + /// + /// The socket. + /// The data to write. + /// The length of data. + /// If protocol is UDP , the destination end point. Otherwise nullptr. + /// Return -1 on error, otherwise bytes written. static int32 WriteSocket(NetworkSocket socket, byte* data, uint32 length, NetworkEndPoint* endPoint = nullptr); + + /// + /// Read data on the socket. + /// + /// The socket. + /// The buffer. + /// Size of the buffer. + /// If UDP, the end point from where data is coming. Otherwise nullptr. + /// Return -1 on error, otherwise bytes read. static int32 ReadSocket(NetworkSocket socket, byte* buffer, uint32 bufferSize, NetworkEndPoint* endPoint = nullptr); + + /// + /// Create an end point. + /// + /// The address (hostname, IPv4 or IPv6). + /// The port. + /// The ip version. + /// The created end point. + /// True if the end point will be connected or binded. + /// Return true on error. Otherwise false. static bool CreateEndPoint(String* address, String* port, NetworkIPVersion ipv, NetworkEndPoint& endPoint, bool bindable = false); + + /// + /// Remap an ipv4 end point to an ipv6 one. + /// + /// The ipv4 end point. + /// The ipv6 end point. static NetworkEndPoint RemapEndPointToIPv6(NetworkEndPoint& endPoint); };