Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

network_socket: added new mutex

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
13/* contains memmove and memcpy */
14#include <string.h>
15
16#include <SDL_thread.h>
17
18/* include this file, it contains some default definitions */
19#include "netdefs.h"
20
21
22/* include base_object.h since all classes are derived from this one */
23#include "base_object.h"
24
25/* using namespace std is default, this needs to be here */
26using namespace std;
27
28class NetworkSocket : public BaseObject
29{
30
31private:
32//  IPaddress serverAddress;
33//  unsigned int port;
34  TCPsocket tcpSocket;
35//  UDPsocket udpSocket;
36
37  byte buf[_INCOMING_BUFFER_SIZE];
38  int bufferlength;
39
40  SDL_mutex * mutex;
41  SDL_mutex * socketmutex;
42  bool terminateThread;
43
44  static int thread_listen(void * data);
45  static int thread_read(void * data);
46
47public:
48
49  NetworkSocket();
50  ~NetworkSocket();
51
52  void connectToServer(IPaddress ip, unsigned int port);
53  void listen(unsigned int port);
54  void disconnectServer();
55  int writeBytes(byte * data, int length);
56  int readBytes(byte * data, int length);
57
58};
59
60
61
62#endif /* _NETWORK_SOCKET */
Note: See TracBrowser for help on using the repository browser.