Skip to content

Commit

Permalink
Update net.hpp
Browse files Browse the repository at this point in the history
  • Loading branch information
xotnet authored Mar 24, 2024
1 parent ce4de78 commit 9160337
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion net.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,17 @@ char* resolve_net(const char* domain) {
return inet_ntoa(addr);
}

char* getPeerIp_net(int socket) {
struct sockaddr_in client_addr;
int addr_len = sizeof(client_addr);
getpeername(socket, (struct sockaddr *)&client_addr, &addr_len);
return inet_ntoa(client_addr.sin_addr);
}

int close_net(int conn) {
#ifdef __WIN32
return closesocket(conn);
#elif __linux__
return close(conn);
#endif
}
}

0 comments on commit 9160337

Please sign in to comment.