playertcp.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00076 #ifndef _PLAYERTCP_H_
00077 #define _PLAYERTCP_H_
00078
00079 #include <sys/types.h>
00080 #include <sys/socket.h>
00081 #include <netinet/in.h>
00082 #include <pthread.h>
00083
00084 #include <libplayercore/playercore.h>
00085
00087 #define PLAYERTCP_DEFAULT_PORT 6665
00088
00091 #define PLAYERTCP_READBUFFER_SIZE 65536
00092
00095 #define PLAYERTCP_WRITEBUFFER_SIZE 65536
00096
00097
00098 struct pollfd;
00099
00100 struct playertcp_listener;
00101 struct playertcp_conn;
00102
00103 class PlayerTCP
00104 {
00105 private:
00106 uint32_t host;
00107 int num_listeners;
00108 playertcp_listener* listeners;
00109 struct pollfd* listen_ufds;
00110
00111 pthread_mutex_t clients_mutex;
00112 int size_clients;
00113 int num_clients;
00114 playertcp_conn* clients;
00115 struct pollfd* client_ufds;
00116
00118 char* decode_readbuffer;
00120 int decode_readbuffersize;
00121
00122 public:
00123 PlayerTCP();
00124 ~PlayerTCP();
00125
00126 pthread_t thread;
00127
00128 int Listen(int* ports, int num_ports);
00129 MessageQueue* AddClient(struct sockaddr_in* cliaddr,
00130 unsigned int local_host,
00131 unsigned int local_port,
00132 int newsock,
00133 bool send_banner,
00134 int* kill_flag);
00135 int Accept(int timeout);
00136 void Close(int cli);
00137 int ReadClient(int cli);
00138 int Read(int timeout);
00139 int Write();
00140 int WriteClient(int cli);
00141 void DeleteClients();
00142 void ParseBuffer(int cli);
00143 int HandlePlayerMessage(int cli, Message* msg);
00144 void DeleteClient(MessageQueue* q);
00145 bool Listening(int port);
00146 uint32_t GetHost() {return host;};
00147 };
00148
00151 #endif
Last updated 12 September 2005 21:38:45
|