Last change
on this file since 5624 was
5624,
checked in by rennerc, 18 years ago
|
network_unit_test.cc: added simple test for network_socket
network_socket: should compile and could work
netdefs.h: changed #ifndef/#define _NETWORK_MANAGER to #ifndef/define _NETDEFS
|
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 */ |
---|
26 | using namespace std; |
---|
27 | |
---|
28 | class NetworkSocket : public BaseObject |
---|
29 | { |
---|
30 | |
---|
31 | private: |
---|
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 | bool terminateThread; |
---|
42 | |
---|
43 | static int thread_listen(void * data); |
---|
44 | static int thread_read(void * data); |
---|
45 | |
---|
46 | public: |
---|
47 | |
---|
48 | NetworkSocket(); |
---|
49 | ~NetworkSocket(); |
---|
50 | |
---|
51 | void connectToServer(IPaddress ip, unsigned int port); |
---|
52 | void listen(unsigned int port); |
---|
53 | void disconnectServer(); |
---|
54 | int writeBytes(byte * data, int length); |
---|
55 | int readBytes(byte * data, int length); |
---|
56 | |
---|
57 | }; |
---|
58 | |
---|
59 | |
---|
60 | |
---|
61 | #endif /* _NETWORK_SOCKET */ |
---|
Note: See
TracBrowser
for help on using the repository browser.