]> git.vomp.tv Git - vompclient.git/blob - tcp.h
Fix resuming recording directly after stopping it
[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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 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 <fcntl.h>
30 #include <ctype.h>
31
32 #ifndef WIN32
33 #include <sys/socket.h>
34 #include <netinet/in.h>
35 #include <unistd.h>
36 #include <arpa/inet.h>
37 #include <sys/ioctl.h>
38 #include <net/if.h>
39 #include <pthread.h>
40 #else
41 #include <winsock2.h>
42 #include <errno.h>
43 #include <Ws2tcpip.h>
44 #endif
45
46 #include "defines.h"
47
48 class TCP
49 {
50   public:
51     TCP();
52     ~TCP();
53
54     int connectTo(char *host, unsigned short port);
55     void assignSocket(int tsocket);
56
57     int isConnected();
58     void disableTimeout();
59
60     int readData(UCHAR* buffer, int totalBytes);
61     int sendData(void *, size_t size);
62
63     static void dump(unsigned char* data, ULONG size);
64
65     void getMAC(char* dest); // copies 6 MAC bytes to dest
66     void setReceiveWindow(size_t rxBufferSize);
67
68   private:
69     int sock;
70     int connected;
71     int timeoutEnabled;
72     int dataLength;
73
74 #ifndef WIN32
75     pthread_mutex_t mutex;
76 #else
77     HANDLE mutex;
78 #endif
79
80     static UCHAR dcc(UCHAR c);
81 };
82
83 #endif