Files
CHOMPStation2/lib/src/netutil.h
Mloc-Argent 49890421f8 Adds a C library alternative to the ircbot nudge script.
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>
2014-03-04 10:08:17 +00:00

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