2424#include <string.h>
2525#include <unistd.h>
2626
27- socket_t socket_listen (const char * address , uint16_t port ) {
28- socket_t fd = socket (AF_INET , SOCK_STREAM , 0 );
27+ libsocket_t socket_listen (const char * address , uint16_t port ) {
28+ libsocket_t fd = socket (AF_INET , SOCK_STREAM , 0 );
2929 if (fd < 0 ) {
3030 return INVALID_SOCKET ;
3131 }
@@ -54,8 +54,8 @@ socket_t socket_listen(const char* address, uint16_t port) {
5454 return fd ;
5555}
5656
57- socket_t socket_accept (socket_t fd ) {
58- socket_t client_fd = accept (fd , NULL , 0 );
57+ libsocket_t socket_accept (libsocket_t fd ) {
58+ libsocket_t client_fd = accept (fd , NULL , 0 );
5959 if (client_fd < 0 ) {
6060 return INVALID_SOCKET ;
6161 }
@@ -78,7 +78,7 @@ socket_t socket_accept(socket_t fd) {
7878 return client_fd ;
7979}
8080
81- socket_t socket_connect (const char * address , uint16_t port ) {
81+ libsocket_t socket_connect (const char * address , uint16_t port ) {
8282 struct addrinfo hint ;
8383 memset (& hint , 0 , sizeof (hint ));
8484 hint .ai_family = AF_UNSPEC ;
@@ -93,7 +93,7 @@ socket_t socket_connect(const char* address, uint16_t port) {
9393 return INVALID_SOCKET ;
9494 }
9595
96- socket_t fd ;
96+ libsocket_t fd ;
9797 struct addrinfo * addr ;
9898 for (addr = result ; addr != NULL ; addr = addr -> ai_next ) {
9999 fd = socket (addr -> ai_family , addr -> ai_socktype , addr -> ai_protocol );
@@ -133,7 +133,7 @@ socket_t socket_connect(const char* address, uint16_t port) {
133133 return fd ;
134134}
135135
136- ssize_t socket_send (socket_t fd , const uint8_t * data , size_t length ) {
136+ ssize_t socket_send (libsocket_t fd , const uint8_t * data , size_t length ) {
137137 ssize_t remaining = length ;
138138 while (remaining > 0 ) {
139139#ifdef __APPLE__
@@ -154,15 +154,15 @@ ssize_t socket_send(socket_t fd, const uint8_t* data, size_t length) {
154154 return length ;
155155}
156156
157- ssize_t socket_recv (socket_t fd , uint8_t * data , size_t length ) {
157+ ssize_t socket_recv (libsocket_t fd , uint8_t * data , size_t length ) {
158158 return read (fd , data , length );
159159}
160160
161- int socket_shutdown (socket_t socket ) {
161+ int socket_shutdown (libsocket_t socket ) {
162162 return shutdown (socket , SHUT_RDWR );
163163}
164164
165- int socket_close (socket_t fd ) {
165+ int socket_close (libsocket_t fd ) {
166166 return close (fd );
167167}
168168
0 commit comments