[rnet] Renamed some functions
This commit is contained in:
parent
e176a476c0
commit
42dad5df95
8 changed files with 83 additions and 83 deletions
|
@ -131,7 +131,7 @@ int main(void)
|
||||||
InitNetworkDevice(); // Init network communications
|
InitNetworkDevice(); // Init network communications
|
||||||
|
|
||||||
// Create the server: getaddrinfo + socket + setsockopt + bind + listen
|
// Create the server: getaddrinfo + socket + setsockopt + bind + listen
|
||||||
serverResult = AllocSocketResult();
|
serverResult = LoadSocketResult();
|
||||||
if (!SocketCreate(&serverConfig, serverResult))
|
if (!SocketCreate(&serverConfig, serverResult))
|
||||||
{
|
{
|
||||||
TraceLog(LOG_WARNING, "Failed to open server: status %d, errno %d", serverResult->status, serverResult->socket->status);
|
TraceLog(LOG_WARNING, "Failed to open server: status %d, errno %d", serverResult->status, serverResult->socket->status);
|
||||||
|
@ -155,7 +155,7 @@ int main(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the client: getaddrinfo + socket + setsockopt + connect (TCP only)
|
// Create the client: getaddrinfo + socket + setsockopt + connect (TCP only)
|
||||||
clientResult = AllocSocketResult();
|
clientResult = LoadSocketResult();
|
||||||
if (!SocketCreate(&clientConfig, clientResult))
|
if (!SocketCreate(&clientConfig, clientResult))
|
||||||
{
|
{
|
||||||
TraceLog(LOG_WARNING, "Failed to open client: status %d, errno %d", clientResult->status, clientResult->socket->status);
|
TraceLog(LOG_WARNING, "Failed to open client: status %d, errno %d", clientResult->status, clientResult->socket->status);
|
||||||
|
@ -172,7 +172,7 @@ int main(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create and add sockets to the socket set
|
// Create and add sockets to the socket set
|
||||||
socketSet = AllocSocketSet(3);
|
socketSet = LoadSocketSet(3);
|
||||||
|
|
||||||
AddSocket(socketSet, serverResult->socket);
|
AddSocket(socketSet, serverResult->socket);
|
||||||
AddSocket(socketSet, clientResult->socket);
|
AddSocket(socketSet, clientResult->socket);
|
||||||
|
|
|
@ -28,7 +28,7 @@ int main(void)
|
||||||
char buffer[ADDRESS_IPV6_ADDRSTRLEN];
|
char buffer[ADDRESS_IPV6_ADDRSTRLEN];
|
||||||
unsigned short port = 0;
|
unsigned short port = 0;
|
||||||
|
|
||||||
AddressInformation *address = AllocAddressList(1);
|
AddressInformation *address = LoadAddressList(1);
|
||||||
|
|
||||||
// Address info flags
|
// Address info flags
|
||||||
// ADDRESS_INFO_NUMERICHOST // or try them in conjunction to
|
// ADDRESS_INFO_NUMERICHOST // or try them in conjunction to
|
||||||
|
|
|
@ -46,7 +46,7 @@ int main(void)
|
||||||
char receiveBuffer[512] = { 0 };
|
char receiveBuffer[512] = { 0 };
|
||||||
|
|
||||||
// Create the client: getaddrinfo + socket + setsockopt + connect (TCP only)
|
// Create the client: getaddrinfo + socket + setsockopt + connect (TCP only)
|
||||||
clientResult = AllocSocketResult();
|
clientResult = LoadSocketResult();
|
||||||
if (!SocketCreate(&clientConfig, clientResult)) TraceLog(LOG_WARNING, "Failed to open client: status %d, errno %d", clientResult->status, clientResult->socket->status);
|
if (!SocketCreate(&clientConfig, clientResult)) TraceLog(LOG_WARNING, "Failed to open client: status %d, errno %d", clientResult->status, clientResult->socket->status);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -57,7 +57,7 @@ int main(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create and add sockets to the socket set
|
// Create and add sockets to the socket set
|
||||||
socketSet = AllocSocketSet(1);
|
socketSet = LoadSocketSet(1);
|
||||||
AddSocket(socketSet, clientResult->socket);
|
AddSocket(socketSet, clientResult->socket);
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
|
|
|
@ -50,7 +50,7 @@ int main(void)
|
||||||
char receiveBuffer[512] = { 0 };
|
char receiveBuffer[512] = { 0 };
|
||||||
|
|
||||||
// Create the server: getaddrinfo + socket + setsockopt + bind + listen
|
// Create the server: getaddrinfo + socket + setsockopt + bind + listen
|
||||||
serverResult = AllocSocketResult();
|
serverResult = LoadSocketResult();
|
||||||
if (!SocketCreate(&serverConfig, serverResult))
|
if (!SocketCreate(&serverConfig, serverResult))
|
||||||
{
|
{
|
||||||
TraceLog(LOG_WARNING, "Failed to open server: status %d, errno %d", serverResult->status, serverResult->socket->status);
|
TraceLog(LOG_WARNING, "Failed to open server: status %d, errno %d", serverResult->status, serverResult->socket->status);
|
||||||
|
@ -71,7 +71,7 @@ int main(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create and add sockets to the socket set
|
// Create and add sockets to the socket set
|
||||||
socketSet = AllocSocketSet(2);
|
socketSet = LoadSocketSet(2);
|
||||||
AddSocket(socketSet, serverResult->socket);
|
AddSocket(socketSet, serverResult->socket);
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
|
|
|
@ -23,17 +23,17 @@ void test_network_initialise()
|
||||||
|
|
||||||
void test_socket_result()
|
void test_socket_result()
|
||||||
{
|
{
|
||||||
SocketResult *result = AllocSocketResult();
|
SocketResult *result = LoadSocketResult();
|
||||||
assert(result != NULL);
|
assert(result != NULL);
|
||||||
FreeSocketResult(&result);
|
UnloadSocketResult(&result);
|
||||||
assert(result == NULL);
|
assert(result == NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_socket()
|
void test_socket()
|
||||||
{
|
{
|
||||||
Socket *socket = AllocSocket();
|
Socket *socket = LoadSocket();
|
||||||
assert(socket != NULL);
|
assert(socket != NULL);
|
||||||
FreeSocket(&socket);
|
UnloadSocket(&socket);
|
||||||
assert(socket == NULL);
|
assert(socket == NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ void test_resolve_host()
|
||||||
{
|
{
|
||||||
const char *address = "localhost";
|
const char *address = "localhost";
|
||||||
const char *port = "80";
|
const char *port = "80";
|
||||||
AddressInformation *addr = AllocAddressList(3);
|
AddressInformation *addr = LoadAddressList(3);
|
||||||
int count = ResolveHost(address, port, ADDRESS_TYPE_ANY, 0, addr);
|
int count = ResolveHost(address, port, ADDRESS_TYPE_ANY, 0, addr);
|
||||||
|
|
||||||
assert(GetAddressFamily(addr[0]) == ADDRESS_TYPE_IPV6);
|
assert(GetAddressFamily(addr[0]) == ADDRESS_TYPE_IPV6);
|
||||||
|
@ -105,9 +105,9 @@ void test_address_list()
|
||||||
void test_socket_create()
|
void test_socket_create()
|
||||||
{
|
{
|
||||||
SocketConfig server_cfg = { .host = "127.0.0.1", .port = "8080", .server = true, .nonblocking = true };
|
SocketConfig server_cfg = { .host = "127.0.0.1", .port = "8080", .server = true, .nonblocking = true };
|
||||||
Socket *socket = AllocSocket();
|
Socket *socket = LoadSocket();
|
||||||
SocketResult *server_res = AllocSocketResult();
|
SocketResult *server_res = LoadSocketResult();
|
||||||
SocketSet *socket_set = AllocSocketSet(1);
|
SocketSet *socket_set = LoadSocketSet(1);
|
||||||
|
|
||||||
assert(SocketCreate(&server_cfg, server_res));
|
assert(SocketCreate(&server_cfg, server_res));
|
||||||
assert(AddSocket(socket_set, server_res->socket));
|
assert(AddSocket(socket_set, server_res->socket));
|
||||||
|
|
|
@ -45,14 +45,14 @@ int main(void)
|
||||||
char receiveBuffer[512] = { 0 };
|
char receiveBuffer[512] = { 0 };
|
||||||
|
|
||||||
// Create the client: getaddrinfo + socket + setsockopt + connect (TCP only)
|
// Create the client: getaddrinfo + socket + setsockopt + connect (TCP only)
|
||||||
clientResult = AllocSocketResult();
|
clientResult = LoadSocketResult();
|
||||||
if (!SocketCreate(&clientConfig, clientResult))
|
if (!SocketCreate(&clientConfig, clientResult))
|
||||||
{
|
{
|
||||||
TraceLog(LOG_WARNING, "Failed to open client: status %d, errno %d", clientResult->status, clientResult->socket->status);
|
TraceLog(LOG_WARNING, "Failed to open client: status %d, errno %d", clientResult->status, clientResult->socket->status);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create and add sockets to the socket set
|
// Create and add sockets to the socket set
|
||||||
socketSet = AllocSocketSet(1);
|
socketSet = LoadSocketSet(1);
|
||||||
AddSocket(socketSet, clientResult->socket);
|
AddSocket(socketSet, clientResult->socket);
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
|
|
|
@ -46,13 +46,13 @@ int main(void)
|
||||||
char receiveBuffer[512] = { 0 };
|
char receiveBuffer[512] = { 0 };
|
||||||
|
|
||||||
// Create the server: getaddrinfo + socket + setsockopt + bind + listen
|
// Create the server: getaddrinfo + socket + setsockopt + bind + listen
|
||||||
serverResult = AllocSocketResult();
|
serverResult = LoadSocketResult();
|
||||||
|
|
||||||
if (!SocketCreate(&serverConfig, serverResult)) TraceLog(LOG_WARNING, "Failed to open server: status %d, errno %d", serverResult->status, serverResult->socket->status);
|
if (!SocketCreate(&serverConfig, serverResult)) TraceLog(LOG_WARNING, "Failed to open server: status %d, errno %d", serverResult->status, serverResult->socket->status);
|
||||||
else if (!SocketBind(&serverConfig, serverResult)) TraceLog(LOG_WARNING, "Failed to bind server: status %d, errno %d", serverResult->status, serverResult->socket->status);
|
else if (!SocketBind(&serverConfig, serverResult)) TraceLog(LOG_WARNING, "Failed to bind server: status %d, errno %d", serverResult->status, serverResult->socket->status);
|
||||||
|
|
||||||
// Create and add sockets to the socket set
|
// Create and add sockets to the socket set
|
||||||
socketSet = AllocSocketSet(1);
|
socketSet = LoadSocketSet(1);
|
||||||
AddSocket(socketSet, serverResult->socket);
|
AddSocket(socketSet, serverResult->socket);
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
|
|
112
src/rnet.h
112
src/rnet.h
|
@ -256,6 +256,11 @@ typedef struct IPAddress {
|
||||||
unsigned short port; // 16-bit protocol port
|
unsigned short port; // 16-bit protocol port
|
||||||
} IPAddress;
|
} IPAddress;
|
||||||
|
|
||||||
|
typedef struct UDPChannel {
|
||||||
|
int numbound; // The total number of addresses this channel is bound to
|
||||||
|
IPAddress address[SOCKET_MAX_UDPADDRESSES]; // The list of remote addresses this channel is bound to
|
||||||
|
} UDPChannel;
|
||||||
|
|
||||||
// An option ID, value, sizeof(value) tuple for setsockopt(2).
|
// An option ID, value, sizeof(value) tuple for setsockopt(2).
|
||||||
typedef struct SocketOpt {
|
typedef struct SocketOpt {
|
||||||
int id; // Socked option id
|
int id; // Socked option id
|
||||||
|
@ -263,17 +268,13 @@ typedef struct SocketOpt {
|
||||||
void *value; // Socked option value data
|
void *value; // Socked option value data
|
||||||
} SocketOpt;
|
} SocketOpt;
|
||||||
|
|
||||||
typedef struct UDPChannel {
|
|
||||||
int numbound; // The total number of addresses this channel is bound to
|
|
||||||
IPAddress address[SOCKET_MAX_UDPADDRESSES]; // The list of remote addresses this channel is bound to
|
|
||||||
} UDPChannel;
|
|
||||||
|
|
||||||
typedef struct Socket {
|
typedef struct Socket {
|
||||||
int ready; // Is the socket ready? i.e. has information
|
int ready; // Is the socket ready? i.e. has information
|
||||||
int status; // The last status code to have occured using this socket
|
int status; // The last status code to have occured using this socket
|
||||||
bool isServer; // Is this socket a server socket (i.e. TCP/UDP Listen Server)
|
bool isServer; // Is this socket a server socket (i.e. TCP/UDP Listen Server)
|
||||||
SocketChannel channel; // The socket handle id
|
SocketChannel channel; // The socket handle id
|
||||||
SocketType type; // Is this socket a TCP or UDP socket?
|
SocketType type; // Is this socket a TCP or UDP socket?
|
||||||
|
|
||||||
bool isIPv6; // Is this socket address an ipv6 address?
|
bool isIPv6; // Is this socket address an ipv6 address?
|
||||||
SocketAddressIPv4 addripv4; // The host/target IPv4 for this socket (in network byte order)
|
SocketAddressIPv4 addripv4; // The host/target IPv4 for this socket (in network byte order)
|
||||||
SocketAddressIPv6 addripv6; // The host/target IPv6 for this socket (in network byte order)
|
SocketAddressIPv6 addripv6; // The host/target IPv6 for this socket (in network byte order)
|
||||||
|
@ -281,6 +282,26 @@ typedef struct Socket {
|
||||||
struct UDPChannel binding[SOCKET_MAX_UDPCHANNELS]; // The amount of channels (if UDP) this socket is bound to
|
struct UDPChannel binding[SOCKET_MAX_UDPCHANNELS]; // The amount of channels (if UDP) this socket is bound to
|
||||||
} Socket;
|
} Socket;
|
||||||
|
|
||||||
|
// Configuration for a socket
|
||||||
|
typedef struct SocketConfig {
|
||||||
|
SocketType type; // The type of socket, TCP/UDP
|
||||||
|
char *host; // The host address in xxx.xxx.xxx.xxx form
|
||||||
|
char *port; // The target port/service in the form "http" or "25565"
|
||||||
|
bool server; // Listen for incoming clients?
|
||||||
|
bool nonblocking; // non-blocking operation?
|
||||||
|
int backlog_size; // set a custom backlog size
|
||||||
|
SocketOpt sockopts[SOCKET_MAX_SOCK_OPTS];
|
||||||
|
} SocketConfig;
|
||||||
|
|
||||||
|
typedef struct SocketDataPacket {
|
||||||
|
IPAddress address; // The source/dest address of an incoming/outgoing packet
|
||||||
|
int channel; // The src/dst channel of the packet
|
||||||
|
int maxlen; // The size of the data buffer
|
||||||
|
int status; // Packet status after sending
|
||||||
|
unsigned int len; // The length of the packet data
|
||||||
|
unsigned char *data; // The packet data
|
||||||
|
} SocketDataPacket;
|
||||||
|
|
||||||
// Result from calling open with a given config
|
// Result from calling open with a given config
|
||||||
typedef struct SocketResult {
|
typedef struct SocketResult {
|
||||||
int status; // Socket result state
|
int status; // Socket result state
|
||||||
|
@ -293,26 +314,6 @@ typedef struct SocketSet {
|
||||||
struct Socket **sockets; // Sockets array
|
struct Socket **sockets; // Sockets array
|
||||||
} SocketSet;
|
} SocketSet;
|
||||||
|
|
||||||
typedef struct SocketDataPacket {
|
|
||||||
IPAddress address; // The source/dest address of an incoming/outgoing packet
|
|
||||||
int channel; // The src/dst channel of the packet
|
|
||||||
int maxlen; // The size of the data buffer
|
|
||||||
int status; // Packet status after sending
|
|
||||||
unsigned int len; // The length of the packet data
|
|
||||||
unsigned char *data; // The packet data
|
|
||||||
} SocketDataPacket;
|
|
||||||
|
|
||||||
// Configuration for a socket
|
|
||||||
typedef struct SocketConfig {
|
|
||||||
SocketType type; // The type of socket, TCP/UDP
|
|
||||||
char *host; // The host address in xxx.xxx.xxx.xxx form
|
|
||||||
char *port; // The target port/service in the form "http" or "25565"
|
|
||||||
bool server; // Listen for incoming clients?
|
|
||||||
bool nonblocking; // non-blocking operation?
|
|
||||||
int backlog_size; // set a custom backlog size
|
|
||||||
SocketOpt sockopts[SOCKET_MAX_SOCK_OPTS];
|
|
||||||
} SocketConfig;
|
|
||||||
|
|
||||||
// Packet type
|
// Packet type
|
||||||
typedef struct Packet {
|
typedef struct Packet {
|
||||||
uint32_t size; // The total size of bytes in data
|
uint32_t size; // The total size of bytes in data
|
||||||
|
@ -347,12 +348,11 @@ int GetAddressSocketType(AddressInformation address);
|
||||||
int GetAddressProtocol(AddressInformation address);
|
int GetAddressProtocol(AddressInformation address);
|
||||||
char *GetAddressCanonName(AddressInformation address);
|
char *GetAddressCanonName(AddressInformation address);
|
||||||
char *GetAddressHostAndPort(AddressInformation address, char *outhost, int *outport);
|
char *GetAddressHostAndPort(AddressInformation address, char *outhost, int *outport);
|
||||||
void PrintAddressInfo(AddressInformation address);
|
|
||||||
|
|
||||||
// Address Memory API
|
// Address Memory API
|
||||||
AddressInformation AllocAddress();
|
AddressInformation LoadAddress(void);
|
||||||
void FreeAddress(AddressInformation *addressInfo);
|
void UnloadAddress(AddressInformation *addressInfo);
|
||||||
AddressInformation *AllocAddressList(int size);
|
AddressInformation *LoadAddressList(int size);
|
||||||
|
|
||||||
// Socket API
|
// Socket API
|
||||||
bool SocketCreate(SocketConfig *config, SocketResult *result);
|
bool SocketCreate(SocketConfig *config, SocketResult *result);
|
||||||
|
@ -361,6 +361,14 @@ bool SocketListen(SocketConfig *config, SocketResult *result);
|
||||||
bool SocketConnect(SocketConfig *config, SocketResult *result);
|
bool SocketConnect(SocketConfig *config, SocketResult *result);
|
||||||
Socket *SocketAccept(Socket *server, SocketConfig *config);
|
Socket *SocketAccept(Socket *server, SocketConfig *config);
|
||||||
|
|
||||||
|
// General Socket API
|
||||||
|
int SocketSend(Socket *sock, const void *datap, int len);
|
||||||
|
int SocketReceive(Socket *sock, void *data, int maxlen);
|
||||||
|
SocketAddressStorage SocketGetPeerAddress(Socket *sock);
|
||||||
|
char *GetSocketAddressHost(SocketAddressStorage storage);
|
||||||
|
short GetSocketAddressPort(SocketAddressStorage storage);
|
||||||
|
void SocketClose(Socket *sock);
|
||||||
|
|
||||||
// UDP Socket API
|
// UDP Socket API
|
||||||
int SocketSetChannel(Socket *socket, int channel, const IPAddress *address);
|
int SocketSetChannel(Socket *socket, int channel, const IPAddress *address);
|
||||||
void SocketUnsetChannel(Socket *socket, int channel);
|
void SocketUnsetChannel(Socket *socket, int channel);
|
||||||
|
@ -372,21 +380,13 @@ void FreePacket(SocketDataPacket *packet);
|
||||||
SocketDataPacket **AllocPacketList(int count, int size);
|
SocketDataPacket **AllocPacketList(int count, int size);
|
||||||
void FreePacketList(SocketDataPacket **packets);
|
void FreePacketList(SocketDataPacket **packets);
|
||||||
|
|
||||||
// General Socket API
|
|
||||||
int SocketSend(Socket *sock, const void *datap, int len);
|
|
||||||
int SocketReceive(Socket *sock, void *data, int maxlen);
|
|
||||||
void SocketClose(Socket *sock);
|
|
||||||
SocketAddressStorage SocketGetPeerAddress(Socket *sock);
|
|
||||||
char* GetSocketAddressHost(SocketAddressStorage storage);
|
|
||||||
short GetSocketAddressPort(SocketAddressStorage storage);
|
|
||||||
|
|
||||||
// Socket Memory API
|
// Socket Memory API
|
||||||
Socket *AllocSocket();
|
Socket *LoadSocket(void);
|
||||||
void FreeSocket(Socket **sock);
|
void UnloadSocket(Socket **sock);
|
||||||
SocketResult *AllocSocketResult();
|
SocketResult *LoadSocketResult(void);
|
||||||
void FreeSocketResult(SocketResult **result);
|
void UnloadSocketResult(SocketResult **result);
|
||||||
SocketSet *AllocSocketSet(int max);
|
SocketSet *LoadSocketSet(int max);
|
||||||
void FreeSocketSet(SocketSet *sockset);
|
void UnloadSocketSet(SocketSet *sockset);
|
||||||
|
|
||||||
// Socket I/O API
|
// Socket I/O API
|
||||||
bool IsSocketReady(Socket *sock);
|
bool IsSocketReady(Socket *sock);
|
||||||
|
@ -1120,7 +1120,7 @@ int ResolveHost(const char *address, const char *service, int addressType, int f
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < size; ++i)
|
for (i = 0; i < size; ++i)
|
||||||
{
|
{
|
||||||
outAddr[i] = AllocAddress();
|
outAddr[i] = LoadAddress();
|
||||||
if (outAddr[i] == NULL)
|
if (outAddr[i] == NULL)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
|
@ -1475,7 +1475,7 @@ Socket *SocketAccept(Socket *server, SocketConfig *config)
|
||||||
|
|
||||||
struct sockaddr_storage sock_addr;
|
struct sockaddr_storage sock_addr;
|
||||||
socklen_t sock_alen;
|
socklen_t sock_alen;
|
||||||
Socket *sock = AllocSocket();
|
Socket *sock = LoadSocket();
|
||||||
server->ready = 0;
|
server->ready = 0;
|
||||||
sock_alen = sizeof(sock_addr);
|
sock_alen = sizeof(sock_addr);
|
||||||
sock->channel = accept(server->channel, (struct sockaddr *)&sock_addr, &sock_alen);
|
sock->channel = accept(server->channel, (struct sockaddr *)&sock_addr, &sock_alen);
|
||||||
|
@ -1863,14 +1863,14 @@ bool IsSocketConnected(Socket *sock)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allocate and return a SocketResult struct
|
// Allocate and return a SocketResult struct
|
||||||
SocketResult *AllocSocketResult(void)
|
SocketResult *LoadSocketResult(void)
|
||||||
{
|
{
|
||||||
struct SocketResult *res = (struct SocketResult *)RNET_MALLOC(sizeof(*res));
|
struct SocketResult *res = (struct SocketResult *)RNET_MALLOC(sizeof(*res));
|
||||||
|
|
||||||
if (res != NULL)
|
if (res != NULL)
|
||||||
{
|
{
|
||||||
memset(res, 0, sizeof(*res));
|
memset(res, 0, sizeof(*res));
|
||||||
if ((res->socket = AllocSocket()) == NULL)
|
if ((res->socket = LoadSocket()) == NULL)
|
||||||
{
|
{
|
||||||
RNET_FREE(res);
|
RNET_FREE(res);
|
||||||
res = NULL;
|
res = NULL;
|
||||||
|
@ -1881,11 +1881,11 @@ SocketResult *AllocSocketResult(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Free an allocated SocketResult
|
// Free an allocated SocketResult
|
||||||
void FreeSocketResult(SocketResult **result)
|
void UnloadSocketResult(SocketResult **result)
|
||||||
{
|
{
|
||||||
if (*result != NULL)
|
if (*result != NULL)
|
||||||
{
|
{
|
||||||
if ((*result)->socket != NULL) FreeSocket(&((*result)->socket));
|
if ((*result)->socket != NULL) UnloadSocket(&((*result)->socket));
|
||||||
|
|
||||||
RNET_FREE(*result);
|
RNET_FREE(*result);
|
||||||
*result = NULL;
|
*result = NULL;
|
||||||
|
@ -1893,7 +1893,7 @@ void FreeSocketResult(SocketResult **result)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allocate a Socket
|
// Allocate a Socket
|
||||||
Socket *AllocSocket(void)
|
Socket *LoadSocket(void)
|
||||||
{
|
{
|
||||||
struct Socket *sock;
|
struct Socket *sock;
|
||||||
sock = (Socket *)RNET_MALLOC(sizeof(*sock));
|
sock = (Socket *)RNET_MALLOC(sizeof(*sock));
|
||||||
|
@ -1911,7 +1911,7 @@ Socket *AllocSocket(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Free an allocated Socket
|
// Free an allocated Socket
|
||||||
void FreeSocket(Socket **sock)
|
void UnloadSocket(Socket **sock)
|
||||||
{
|
{
|
||||||
if (*sock != NULL)
|
if (*sock != NULL)
|
||||||
{
|
{
|
||||||
|
@ -1921,7 +1921,7 @@ void FreeSocket(Socket **sock)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allocate a SocketSet
|
// Allocate a SocketSet
|
||||||
SocketSet *AllocSocketSet(int max)
|
SocketSet *LoadSocketSet(int max)
|
||||||
{
|
{
|
||||||
struct SocketSet *set = (struct SocketSet *)RNET_MALLOC(sizeof(*set));
|
struct SocketSet *set = (struct SocketSet *)RNET_MALLOC(sizeof(*set));
|
||||||
|
|
||||||
|
@ -1945,7 +1945,7 @@ SocketSet *AllocSocketSet(int max)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Free an allocated SocketSet
|
// Free an allocated SocketSet
|
||||||
void FreeSocketSet(SocketSet *set)
|
void UnloadSocketSet(SocketSet *set)
|
||||||
{
|
{
|
||||||
if (set)
|
if (set)
|
||||||
{
|
{
|
||||||
|
@ -2053,7 +2053,7 @@ int CheckSockets(SocketSet *set, unsigned int timeout)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allocate an AddressInformation
|
// Allocate an AddressInformation
|
||||||
AddressInformation AllocAddress(void)
|
AddressInformation LoadAddress(void)
|
||||||
{
|
{
|
||||||
AddressInformation addressInfo = NULL;
|
AddressInformation addressInfo = NULL;
|
||||||
addressInfo = (AddressInformation)RNET_CALLOC(1, sizeof(*addressInfo));
|
addressInfo = (AddressInformation)RNET_CALLOC(1, sizeof(*addressInfo));
|
||||||
|
@ -2069,7 +2069,7 @@ AddressInformation AllocAddress(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Free an AddressInformation struct
|
// Free an AddressInformation struct
|
||||||
void FreeAddress(AddressInformation *addressInfo)
|
void UnloadAddress(AddressInformation *addressInfo)
|
||||||
{
|
{
|
||||||
if (*addressInfo != NULL)
|
if (*addressInfo != NULL)
|
||||||
{
|
{
|
||||||
|
@ -2085,7 +2085,7 @@ void FreeAddress(AddressInformation *addressInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allocate a list of AddressInformation
|
// Allocate a list of AddressInformation
|
||||||
AddressInformation *AllocAddressList(int size)
|
AddressInformation *LoadAddressList(int size)
|
||||||
{
|
{
|
||||||
AddressInformation *addr;
|
AddressInformation *addr;
|
||||||
addr = (AddressInformation *)RNET_MALLOC(size * sizeof(AddressInformation));
|
addr = (AddressInformation *)RNET_MALLOC(size * sizeof(AddressInformation));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue