Netsocket changes

This commit is contained in:
Cacodemon345
2024-03-12 01:55:17 +06:00
parent 9f5d2a46bd
commit 10e0dbaafa
2 changed files with 6 additions and 1 deletions

View File

@@ -16,7 +16,7 @@ SOCKET plat_netsocket_create_server(int type, unsigned short port);
void plat_netsocket_close(SOCKET socket);
SOCKET plat_netsocket_accept(SOCKET socket);
int plat_netsocket_connected(SOCKET socket);
int plat_netsocket_connected(SOCKET socket); /* Returns -1 on trouble. */
int plat_netsocket_connect(SOCKET socket, const char* hostname, unsigned short port);
/* Returns 0 in case of inability to send. -1 in case of errors. */

View File

@@ -80,6 +80,9 @@ int plat_netsocket_connected(SOCKET socket)
{
struct sockaddr addr;
socklen_t len = sizeof(struct sockaddr);
if (getpeername(socket, &addr, &len) == SOCKET_ERROR)
return 0;
@@ -113,6 +116,8 @@ int plat_netsocket_connect(SOCKET socket, const char* hostname, unsigned short p
if (error == WSAEISCONN)
return 0;
res = -1;
}
return res;
}