Search Results for

    Show / Hide Table of Contents

    Class NetworkBase

    Low-level networking implementation interface with Berkeley sockets.

    Inheritance
    NetworkBase
    Assembly: FlaxEngine.dll
    File: Engine/Platform/Base/NetworkBase.h
    Syntax
    public class NetworkBase

    Fields

    TypeInitializer

    Declaration
    public static struct FLAXENGINE_API ScriptingTypeInitializer TypeInitializer
    Field Value
    struct FLAXENGINE_API ScriptingTypeInitializer

    Methods

    Accept(NetworkSocket& serverSocket, NetworkSocket& newSocket, NetworkEndPoint& newEndPoint)

    Accepts a pending connection.

    Declaration
    public static bool Accept(NetworkSocket& serverSocket, NetworkSocket& newSocket, NetworkEndPoint& newEndPoint)
    Parameters
    NetworkSocket serverSocket

    The socket.

    NetworkSocket newSocket

    The newly connected socket.

    NetworkEndPoint newEndPoint

    The end point of the new socket.

    Returns
    bool

    Returns true on error, otherwise false.

    AddSocketToGroup(NetworkSocketGroup& group, NetworkSocket& socket)

    Adds a socket to a group.

    Declaration
    public static int32 AddSocketToGroup(NetworkSocketGroup& group, NetworkSocket& socket)
    Parameters
    NetworkSocketGroup group

    The group.

    NetworkSocket socket

    The socket.

    Returns
    int32

    Returns the socket index in group or -1 on error.

    BindSocket(NetworkSocket& socket, NetworkEndPoint& endPoint)

    Binds a socket to the specified end point.

    Declaration
    public static bool BindSocket(NetworkSocket& socket, NetworkEndPoint& endPoint)
    Parameters
    NetworkSocket socket

    The socket.

    NetworkEndPoint endPoint

    The end point.

    Returns
    bool

    Returns true on error, otherwise false.

    ClearGroup(NetworkSocketGroup& group)

    Clears the socket group.

    Declaration
    public static void ClearGroup(NetworkSocketGroup& group)
    Parameters
    NetworkSocketGroup group

    The group.

    ConnectSocket(NetworkSocket& socket, NetworkEndPoint& endPoint)

    Connects a socket to the specified end point.

    Declaration
    public static bool ConnectSocket(NetworkSocket& socket, NetworkEndPoint& endPoint)
    Parameters
    NetworkSocket socket

    The socket.

    NetworkEndPoint endPoint

    The end point.

    Returns
    bool

    Returns true on error, otherwise false.

    CreateEndPoint(const String& address, const String& port, NetworkIPVersion ipv, NetworkEndPoint& endPoint, bool bindable=true)

    Creates an end point.

    Declaration
    public static bool CreateEndPoint(const String& address, const String& port, NetworkIPVersion ipv, NetworkEndPoint& endPoint, bool bindable=true)
    Parameters
    String address

    The network address.

    String port

    The network port.

    NetworkIPVersion ipv

    The ip version.

    NetworkEndPoint endPoint

    The created end point.

    bool bindable

    True if the end point will be connected or binded.

    Returns
    bool

    Returns true on error, otherwise false.

    CreateSocket(NetworkSocket& socket, NetworkProtocol proto, NetworkIPVersion ipv)

    Creates a new native socket.

    Declaration
    public static bool CreateSocket(NetworkSocket& socket, NetworkProtocol proto, NetworkIPVersion ipv)
    Parameters
    NetworkSocket socket

    The socket struct to fill in.

    NetworkProtocol proto

    The protocol.

    NetworkIPVersion ipv

    The ip version.

    Returns
    bool

    Returns true on error, otherwise false.

    CreateSocketGroup(uint32 capacity, NetworkSocketGroup& group)

    Creates a socket group. It allocate memory based on the desired capacity.

    Declaration
    public static bool CreateSocketGroup(uint32 capacity, NetworkSocketGroup& group)
    Parameters
    uint32 capacity

    The group capacity (fixed).

    NetworkSocketGroup group

    The group.

    Returns
    bool

    Returns true on error, otherwise false.

    DestroySocket(NetworkSocket& socket)

    Closes native socket.

    Declaration
    public static bool DestroySocket(NetworkSocket& socket)
    Parameters
    NetworkSocket socket

    The socket.

    Returns
    bool

    Returns true on error, otherwise false.

    DestroySocketGroup(NetworkSocketGroup& group)

    Destroy the socket group, and free the allocated memory.

    Declaration
    public static bool DestroySocketGroup(NetworkSocketGroup& group)
    Parameters
    NetworkSocketGroup group

    The group.

    Returns
    bool

    Returns true if the group is already destroyed, otherwise false.

    GetSocketFromGroup(NetworkSocketGroup& group, uint32 index, NetworkSocket& socket)

    Gets a socket by index. Some data like socket IPVersion might be undefined.

    Declaration
    public static bool GetSocketFromGroup(NetworkSocketGroup& group, uint32 index, NetworkSocket& socket)
    Parameters
    NetworkSocketGroup group

    The group.

    uint32 index

    The index.

    NetworkSocket socket

    The returned socket.

    Returns
    bool

    Returns true on error, otherwise false.

    GetSocketOption(NetworkSocket& socket, NetworkSocketOption option, int32& value)

    Gets the specified socket option.

    Declaration
    public static bool GetSocketOption(NetworkSocket& socket, NetworkSocketOption option, int32& value)
    Parameters
    NetworkSocket socket

    The socket.

    NetworkSocketOption option

    The option.

    int32 value

    The returned value.

    Returns
    bool

    Returns true on error, otherwise false.

    GetSocketState(NetworkSocketGroup& group, uint32 index, NetworkSocketState& state)

    Retrieves socket state.

    Declaration
    public static bool GetSocketState(NetworkSocketGroup& group, uint32 index, NetworkSocketState& state)
    Parameters
    NetworkSocketGroup group

    The group.

    uint32 index

    The socket index in group.

    NetworkSocketState state

    The returned state.

    Returns
    bool

    Returns true on error, otherwise false.

    IsReadable(NetworkSocket& socket)

    Checks for socket readability.

    Declaration
    public static bool IsReadable(NetworkSocket& socket)
    Parameters
    NetworkSocket socket

    The socket.

    Returns
    bool

    Returns true when data is available. Otherwise false.

    IsWritable(NetworkSocket& socket)

    Checks for socket writeability.

    Declaration
    public static bool IsWritable(NetworkSocket& socket)
    Parameters
    NetworkSocket socket

    The socket.

    Returns
    bool

    Returns true when data can be written. Otherwise false.

    Listen(NetworkSocket& socket, uint16 queueSize)

    Listens for incoming connection.

    Declaration
    public static bool Listen(NetworkSocket& socket, uint16 queueSize)
    Parameters
    NetworkSocket socket

    The socket.

    uint16 queueSize

    Pending connection queue size.

    Returns
    bool

    Returns true on error, otherwise false.

    Poll(NetworkSocketGroup& group)

    Updates sockets states.

    Declaration
    public static int32 Poll(NetworkSocketGroup& group)
    Parameters
    NetworkSocketGroup group

    The sockets group.

    Returns
    int32

    Returns -1 on error, The number of elements where states are nonzero, otherwise 0.

    ReadSocket(NetworkSocket socket, byte* buffer, uint32 bufferSize, NetworkEndPoint* endPoint=nullptr)

    Reads data on the socket.

    Declaration
    public static int32 ReadSocket(NetworkSocket socket, byte* buffer, uint32 bufferSize, NetworkEndPoint* endPoint=nullptr)
    Parameters
    NetworkSocket socket

    The socket.

    byte buffer

    The buffer.

    uint32 bufferSize

    Size of the buffer.

    NetworkEndPoint endPoint

    If UDP, the end point from where data is coming. Otherwise nullptr.

    Returns
    int32

    Returns -1 on error, otherwise bytes read.

    RemapEndPointToIPv6(NetworkEndPoint& endPoint)

    Remaps an ipv4 end point to an ipv6 one.

    Declaration
    public static NetworkEndPoint RemapEndPointToIPv6(NetworkEndPoint& endPoint)
    Parameters
    NetworkEndPoint endPoint

    The ipv4 end point.

    Returns
    NetworkEndPoint

    The ipv6 end point.

    RemoveSocketFromGroup(NetworkSocketGroup& group, NetworkSocket& socket)

    Removes the socket if present.

    Declaration
    public static bool RemoveSocketFromGroup(NetworkSocketGroup& group, NetworkSocket& socket)
    Parameters
    NetworkSocketGroup group

    The group.

    NetworkSocket socket

    The socket.

    Returns
    bool

    Returns true if the socket is not found, otherwise false.

    RemoveSocketFromGroup(NetworkSocketGroup& group, uint32 index)

    Removes the socket at the specified index.

    Declaration
    public static void RemoveSocketFromGroup(NetworkSocketGroup& group, uint32 index)
    Parameters
    NetworkSocketGroup group

    The group.

    uint32 index

    The index.

    SetSocketOption(NetworkSocket& socket, NetworkSocketOption option, int32 value)

    Sets the specified socket option.

    Declaration
    public static bool SetSocketOption(NetworkSocket& socket, NetworkSocketOption option, int32 value)
    Parameters
    NetworkSocket socket

    The socket.

    NetworkSocketOption option

    The option.

    int32 value

    The value.

    Returns
    bool

    Returns true on error, otherwise false.

    WriteSocket(NetworkSocket socket, byte* data, uint32 length, NetworkEndPoint* endPoint=nullptr)

    Writes data to the socket.

    Declaration
    public static int32 WriteSocket(NetworkSocket socket, byte* data, uint32 length, NetworkEndPoint* endPoint=nullptr)
    Parameters
    NetworkSocket socket

    The socket.

    byte data

    The data to write.

    uint32 length

    The length of data.

    NetworkEndPoint endPoint

    If protocol is UDP, the destination end point. Otherwise nullptr.

    Returns
    int32

    Returns -1 on error, otherwise bytes written.

    • Improve this Doc
    • View Source
    In This Article
    Back to top Copyright © 2012-2024 Wojciech Figat