mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 18:22:39 +00:00
This allows for more secure and stable transmission on Linux, but you might see some improvements on Windows too. Code lies in (confusingly) lib/src. nudge.c should be compiled to lib/nudge.[dll/so] and be linked against netutil.c. There's some horribly hacky code in nudge.c to assemble pickled data, but it's probably the fastest way that's still safe. Signed-off-by: Mloc-Argent <colmohici@gmail.com>
34 lines
537 B
C
34 lines
537 B
C
#ifndef NETUTIL_H
|
|
#define NETUTIL_H
|
|
|
|
#ifdef _WIN32
|
|
|
|
#include <winsock2.h>
|
|
#include <ws2tcpip.h>
|
|
typedef SOCKET socket_t;
|
|
|
|
#define close_socket(sock) closesocket(sock)
|
|
|
|
#else
|
|
|
|
#include <sys/types.h>
|
|
#include <sys/socket.h>
|
|
#include <netdb.h>
|
|
#include <unistd.h>
|
|
typedef int socket_t;
|
|
|
|
#define close_socket(sock) close(sock)
|
|
|
|
#endif
|
|
|
|
extern int net_ready;
|
|
void init_net();
|
|
|
|
socket_t connect_sock(char * host, char * port);
|
|
|
|
void send_n(socket_t sock, const char * buf, size_t n);
|
|
void recv_n(socket_t sock, char * buf, size_t n);
|
|
|
|
#endif
|
|
|