*push*
[NeonServV5.git] / ClientSocket.h
1 #ifndef _ClientSocket_h
2 #define _ClientSocket_h
3
4 #include "main.h"
5
6 #define SOCKET_FLAG_DEAD 0x01;
7 #define SOCKET_FLAG_CONNECTED 0x02;
8 #define SOCKET_FLAG_READY 0x04;
9
10 #define BUF_SIZ 512
11
12 struct UserNode;
13
14 struct ClientSocket {
15     int sock;
16     unsigned char flags;
17     char buffer[BUF_SIZ*2]; //we need to store up to 2 full commands at once
18     unsigned int bufferpos;
19     char *host;
20     int port;
21     char *pass;
22     struct UserNode *user;
23     
24     struct ClientSocket *next;
25 };
26
27 struct ClientSocket* create_socket(char *host, int port, char *pass, struct UserNode *user);
28 int connect_socket(struct ClientSocket *client);
29 int close_socket(struct ClientSocket *client);
30 int write_socket(struct ClientSocket *client, char* msg, int len);
31 void socket_loop(int timeout_seconds);
32
33 #endif