NetIO.h File Reference

NETIO is a simple cross-platform API for accessing UDP and TCP sockets. More...

#include <libos/Defines.h>
Include dependency graph for NetIO.h:

Go to the source code of this file.

Classes

struct  losCreateSocketInfo
 losCreateSocketInfo is the socket creation struct we pass this into the creation function for the library to create a socket object More...
 
struct  losUdpData
 simple wrapper used to handle UDP data on the server side More...
 

Typedefs

typedef struct losSocket_T * losSocket
 this is the Library object that is used to read and write network data to and from the Native Socket as the user only holds a pointer to the library object that is controlled by the library. More...
 
typedef enum losSocketBit losSocketBit
 losSocketBit is used for socket object flags
 
typedef struct losCreateSocketInfo losCreateSocketInfo
 losCreateSocketInfo is the socket creation struct we pass this into the creation function for the library to create a socket object
 
typedef struct losUdpData losUdpData
 simple wrapper used to handle UDP data on the server side
 

Enumerations

enum  losSocketBit : uint8_t { LOS_SOCKET_UDP = 0x001 , LOS_SOCKET_TCP = 0x002 , LOS_SOCKET_APF = 0x004 , LOS_SOCKET_SERVER = 0x008 }
 losSocketBit is used for socket object flags More...
 

Functions

EXPORT_DLL uint32_t * losNetworkBytesToSystemBytes (_in_ const uint32_t *bytes, _in_ const size_t bytes_size)
 losNetworkBytesToSystemBytes converts from big-endian to little-endian(for now as we have not got an arm platform to work with) More...
 
EXPORT_DLL uint32_t * losSystemBytesToNetworkBytes (_in_ const uint32_t *bytes, _in_ const size_t bytes_size)
 losSystemBytesToNetworkBytes converts from little-endian to big-endian(for now as we have not got an arm platform to work with) More...
 
EXPORT_DLL int32_t * losNetworkBytesToSystemBytesSigned (_in_ const int32_t *bytes, _in_ const size_t bytes_size)
 losNetworkBytesToSystemBytesSigned converts signed from big-endian to little-endian(for now as we have not got an arm platform to work with) More...
 
EXPORT_DLL int32_t * losSystemBytesToNetworkBytesSigned (_in_ const int32_t *bytes, _in_ const size_t bytes_size)
 losSystemBytesToNetworkBytesSigned converts signed from little-endian to big-endian(for now as we have not got an arm platform to work with) More...
 
EXPORT_DLL losResult losCreateSocket (_out_ losSocket *handle, _in_ const losCreateSocketInfo &socket_info)
 losCreateSocket is to create the library object but dose not release the object to the library user More...
 
EXPORT_DLL losResult losReadSocket (_in_ const losSocket handle, _out_ void *buffer, _in_ const size_t bytes_to_read)
 losReadSocket read data from native socket held by the library object (NOTE: for server side udp it is required to use a losUdpData struct to wrap the buffer to receive data correctly) More...
 
EXPORT_DLL losResult losWaitForClient (_in_ const losSocket handle, _out_ losSocket *new_client)
 losWaitForClient is for server side TCP connection only we use this to wait for client connections and return a library object of the connected client More...
 
EXPORT_DLL losResult losWriteSocket (_in_ const losSocket handle, _in_ const void *buffer, _in_ const size_t buffer_size)
 losWriteSocket write data to native socket held by the library object (NOTE: for server side udp it is required to use a losUdpData struct to wrap the buffer to send data correctly) More...
 
EXPORT_DLL losResult losDestroySocket (_in_ losSocket handle)
 losDestroySocket is to close the library object and safely delete it More...
 

Detailed Description

NETIO is a simple cross-platform API for accessing UDP and TCP sockets.

Author
Luke Shore luket.nosp@m.hemo.nosp@m.dded@.nosp@m.gmai.nosp@m.l.com
Version
1.0
Date
05/12/2022

Typedef Documentation

◆ losSocket

typedef struct losSocket_T* losSocket

this is the Library object that is used to read and write network data to and from the Native Socket as the user only holds a pointer to the library object that is controlled by the library.

Importation of libraries

Enumeration Type Documentation

◆ losSocketBit

enum losSocketBit : uint8_t

losSocketBit is used for socket object flags

Enumerator
LOS_SOCKET_UDP 

set socket to UDP socket flag bit

LOS_SOCKET_TCP 

set socket to TCP socket flag bit

LOS_SOCKET_APF 

this is for automatically port forwarding in the router flag bit (NOT_IMPLEMENTED)

LOS_SOCKET_SERVER 

this is to tell the library that the socket is to be used as a server

Function Documentation

◆ losCreateSocket()

EXPORT_DLL losResult losCreateSocket ( _out_ losSocket handle,
_in_ const losCreateSocketInfo socket_info 
)

losCreateSocket is to create the library object but dose not release the object to the library user

Parameters
[out]handle
[in]socket_info
Returns
losResult

◆ losDestroySocket()

EXPORT_DLL losResult losDestroySocket ( _in_ losSocket  handle)

losDestroySocket is to close the library object and safely delete it

Parameters
[in]handle
Returns
losResult

◆ losNetworkBytesToSystemBytes()

EXPORT_DLL uint32_t* losNetworkBytesToSystemBytes ( _in_ const uint32_t *  bytes,
_in_ const size_t  bytes_size 
)

losNetworkBytesToSystemBytes converts from big-endian to little-endian(for now as we have not got an arm platform to work with)

Parameters
[out]bytes
[in]bytes_size
Returns
losResult

◆ losNetworkBytesToSystemBytesSigned()

EXPORT_DLL int32_t* losNetworkBytesToSystemBytesSigned ( _in_ const int32_t *  bytes,
_in_ const size_t  bytes_size 
)

losNetworkBytesToSystemBytesSigned converts signed from big-endian to little-endian(for now as we have not got an arm platform to work with)

Parameters
[out]bytes
[in]bytes_size
Returns
losResult

◆ losReadSocket()

EXPORT_DLL losResult losReadSocket ( _in_ const losSocket  handle,
_out_ void *  buffer,
_in_ const size_t  bytes_to_read 
)

losReadSocket read data from native socket held by the library object (NOTE: for server side udp it is required to use a losUdpData struct to wrap the buffer to receive data correctly)

Parameters
[in]handle
[out]buffer
[in]bytes_to_read
Returns
losResult

◆ losSystemBytesToNetworkBytes()

EXPORT_DLL uint32_t* losSystemBytesToNetworkBytes ( _in_ const uint32_t *  bytes,
_in_ const size_t  bytes_size 
)

losSystemBytesToNetworkBytes converts from little-endian to big-endian(for now as we have not got an arm platform to work with)

Parameters
[out]bytes
[in]bytes_size
Returns
losResult

◆ losSystemBytesToNetworkBytesSigned()

EXPORT_DLL int32_t* losSystemBytesToNetworkBytesSigned ( _in_ const int32_t *  bytes,
_in_ const size_t  bytes_size 
)

losSystemBytesToNetworkBytesSigned converts signed from little-endian to big-endian(for now as we have not got an arm platform to work with)

Parameters
[out]bytes
[in]bytes_size
Returns
losResult

◆ losWaitForClient()

EXPORT_DLL losResult losWaitForClient ( _in_ const losSocket  handle,
_out_ losSocket new_client 
)

losWaitForClient is for server side TCP connection only we use this to wait for client connections and return a library object of the connected client

Parameters
[in]handle
[out]new_client
Returns
losResult

◆ losWriteSocket()

EXPORT_DLL losResult losWriteSocket ( _in_ const losSocket  handle,
_in_ const void *  buffer,
_in_ const size_t  buffer_size 
)

losWriteSocket write data to native socket held by the library object (NOTE: for server side udp it is required to use a losUdpData struct to wrap the buffer to send data correctly)

Parameters
[in]handle
[in]buffer
[in]buffer_size
Returns
losResult