Debian Codegraph @

src/io/network.h

raw symbols SCIP
1
2 /**
3 *
4 * @file network.h
5 *
6 * Part of the OpenJazz project
7 *
8 * @par History:
9 * - 23rd August 2005: Created OpenJazz.h
10 * - 3rd June 2009: Created network.h from parts of OpenJazz.h
11 *
12 * @par Licence:
13 * Copyright (c) 2005-2017 AJ Thomson
14 *
15 * OpenJazz is distributed under the terms of
16 * the GNU General Public License, version 2.0
17 *
18 */
19
20 #ifndef _NETWORK_H
21 #define _NETWORK_H
22
23
24 #include "OpenJazz.h"
25
26 #ifdef USE_SDL_NET
27 #include <SDL_net.h>
28 #endif
29
30 // Constants
31
32 // Defaults
33 #if defined(DINGOO)
34 #define NET_ADDRESS "10.1.0.1"
35 #else
36 #define NET_ADDRESS "192.168.0.1"
37 #endif
38 #define NET_PORT 10052
39
40 // Timeout interval
41 #define T_TIMEOUT 30000
42
43 // Client limit
44 #define MAX_CLIENTS 31
45
46 // Level file
47 #define LEVEL_FILE "openjazz.tmp"
48
49
50 // Class
51
52 /// Networking
53 class Network {
54
55 public:
56 #ifdef USE_SDL_NET
57 TCPsocket socket;
58 TCPsocket clientSocket;
59 IPaddress ipAddress;
60 SDLNet_SocketSet socketset;
61 #endif
62
63 Network ();
64 ~Network ();
65
66 int host ();
67 int join (char *address);
68 int accept (int sock);
69 void close (int sock);
70 int send (int sock, unsigned char *buffer);
71 int recv (int sock, unsigned char *buffer, int length);
72 bool isConnected (int sock);
73 int getError ();
74
75 };
76
77
78 // Variables
79
80 EXTERN char *netAddress; /// Server address
81 EXTERN Network *net;
82
83 #endif
84