timesynk/old/net/sockets.h

49 lines
1.1 KiB
C

#ifndef SOCKETS_H
#define SOCKETS_H
#if _WIN32 | _WIN64
#include <Windows.h>
#include <Ws2tcpip.h>
#include <Winsock2.h>
#else
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <unistd.h>
#if defined (sun)
/* For Solaris 2.6, as it lacks SIOCGIFCONF */
#include <sys/sockio.h>
#endif
#endif
void *get_in_addr(struct sockaddr *sa);
int sendall(int socket, char *buffer, int length);
int net_socket;
struct sockaddr_in server_address;
fd_set master_fds;
fd_set read_fds;
int max_fd;
struct NetMessage {
int fd;
int size;
void *data;
};
int client_socket; // send/recv socket for clients only
struct sockaddr_in connected_address;
/* console commands */
// handles input "servername port" and calls netConnect
void consoleNetConnect(const char *input_string);
// simply calls netDisconnect
void consoleNetDisconnect();
// sends a message to server // NOTE: will be removed, just for testing
void consoleNetSend(const char *message);
/* client-> server funcs */
int netConnect(const char *server_string, const char *port_string);
int netDisconnect();
#endif