Use sc_ prefix for sockets

Rename:
 - socket_t to sc_socket
 - INVALID_SOCKET to SC_INVALID_SOCKET
This commit is contained in:
Romain Vimont
2021-10-26 22:49:45 +02:00
parent eb6afe7669
commit 3adff37c2d
10 changed files with 78 additions and 73 deletions

View File

@@ -8,15 +8,19 @@
#include <SDL2/SDL_platform.h>
#ifdef __WINDOWS__
# include <winsock2.h>
#define SHUT_RD SD_RECEIVE
#define SHUT_WR SD_SEND
#define SHUT_RDWR SD_BOTH
typedef SOCKET socket_t;
#else
# define SHUT_RD SD_RECEIVE
# define SHUT_WR SD_SEND
# define SHUT_RDWR SD_BOTH
# define SC_INVALID_SOCKET INVALID_SOCKET
typedef SOCKET sc_socket;
#else // not __WINDOWS__
# include <sys/socket.h>
# define INVALID_SOCKET -1
typedef int socket_t;
# define SC_INVALID_SOCKET -1
typedef int sc_socket;
#endif
bool
@@ -25,33 +29,33 @@ net_init(void);
void
net_cleanup(void);
socket_t
sc_socket
net_connect(uint32_t addr, uint16_t port);
socket_t
sc_socket
net_listen(uint32_t addr, uint16_t port, int backlog);
socket_t
net_accept(socket_t server_socket);
sc_socket
net_accept(sc_socket server_socket);
// the _all versions wait/retry until len bytes have been written/read
ssize_t
net_recv(socket_t socket, void *buf, size_t len);
net_recv(sc_socket socket, void *buf, size_t len);
ssize_t
net_recv_all(socket_t socket, void *buf, size_t len);
net_recv_all(sc_socket socket, void *buf, size_t len);
ssize_t
net_send(socket_t socket, const void *buf, size_t len);
net_send(sc_socket socket, const void *buf, size_t len);
ssize_t
net_send_all(socket_t socket, const void *buf, size_t len);
net_send_all(sc_socket socket, const void *buf, size_t len);
// how is SHUT_RD (read), SHUT_WR (write) or SHUT_RDWR (both)
bool
net_shutdown(socket_t socket, int how);
net_shutdown(sc_socket socket, int how);
bool
net_close(socket_t socket);
net_close(sc_socket socket);
#endif