Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/network/src/lib/network/network_socket.h @ 5628

Last change on this file since 5628 was 5628, checked in by rennerc, 18 years ago

network_unit_test.cc: added test for much data
network_socket: added delay if input buffer is full

File size: 1.2 KB
Line 
1/*!
2 * @file network_socket.h
3  *  Main interface for the network module. Manages all the modules
4
5*/
6
7#ifndef _NETWORK_SOCKET
8#define _NETWORK_SOCKET
9
10#define _INCOMING_BUFFER_SIZE 10240
11#define _LOCAL_BUFFER_SIZE 1024
12#define _MSECONDS_SLEEP_FULL_BUFFER 10
13
14/* contains memmove and memcpy */
15#include <string.h>
16
17#include <SDL_thread.h>
18
19/* include this file, it contains some default definitions */
20#include "netdefs.h"
21
22
23/* include base_object.h since all classes are derived from this one */
24#include "base_object.h"
25
26/* using namespace std is default, this needs to be here */
27using namespace std;
28
29class NetworkSocket : public BaseObject
30{
31
32private:
33//  IPaddress serverAddress;
34//  unsigned int port;
35  TCPsocket tcpSocket;
36//  UDPsocket udpSocket;
37
38  byte buf[_INCOMING_BUFFER_SIZE];
39  int bufferlength;
40
41  SDL_mutex * mutex;
42  SDL_mutex * socketmutex;
43  bool terminateThread;
44
45  static int thread_listen(void * data);
46  static int thread_read(void * data);
47
48public:
49
50  NetworkSocket();
51  ~NetworkSocket();
52
53  void connectToServer(IPaddress ip, unsigned int port);
54  void listen(unsigned int port);
55  void disconnectServer();
56  int writeBytes(byte * data, int length);
57  int readBytes(byte * data, int length);
58
59};
60
61
62
63#endif /* _NETWORK_SOCKET */
Note: See TracBrowser for help on using the repository browser.