]> git.vomp.tv Git - vompclient.git/blob - tcp.h
Initial import
[vompclient.git] / tcp.h
1 /*
2     Copyright 2004-2005 Chris Tallon
3     Copyright 2003-2004 University Of Bradford
4
5     This file is part of VOMP.
6
7     VOMP is free software; you can redistribute it and/or modify
8     it under the terms of the GNU General Public License as published by
9     the Free Software Foundation; either version 2 of the License, or
10     (at your option) any later version.
11
12     VOMP is distributed in the hope that it will be useful,
13     but WITHOUT ANY WARRANTY; without even the implied warranty of
14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15     GNU General Public License for more details.
16
17     You should have received a copy of the GNU General Public License
18     along with VOMP; if not, write to the Free Software
19     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20 */
21
22 #ifndef TCP_H
23 #define TCP_H
24
25 #include <stdio.h>
26 #include <string.h>
27 #include <stdlib.h>
28 #include <errno.h>
29 #include <sys/socket.h>
30 #include <netinet/in.h>
31 #include <unistd.h>
32 #include <sys/socket.h>
33 #include <arpa/inet.h>
34 #include <fcntl.h>
35 #include <ctype.h>
36
37 #include "defines.h"
38 #include "log.h"
39
40 class TCP
41 {
42   public:
43     TCP();
44     ~TCP();
45
46     int connectTo(char *host, unsigned short port);
47     void assignSocket(int tsocket);
48
49     int isConnected();
50     void disableTimeout();
51
52     int sendPacket(void *, size_t size);
53     UCHAR* receivePacket();
54     int getDataLength();
55
56     int readData(UCHAR* buffer, int totalBytes);
57
58     static void dump(unsigned char* data, ULONG size);
59
60   private:
61     int sock;
62     int connected;
63     int timeoutEnabled;
64     int dataLength;
65
66     static UCHAR dcc(UCHAR c);
67 };
68
69 #endif