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 Alister Thomson
14  *
15  * OpenJazz is distributed under the terms of
16  * the GNU General Public License, version 2.0
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21  *
22  */
23 
24 #ifndef _NETWORK_H
25 #define _NETWORK_H
26 
27 
28 #include "OpenJazz.h"
29 
30 #ifdef USE_SDL_NET
31 #include <SDL_net.h>
32 #endif
33 
34 // Constants
35 
36 // Defaults
37 #if defined(DINGOO)
38 	#define NET_ADDRESS "10.1.0.1"
39 #else
40 	#define NET_ADDRESS "192.168.0.1"
41 #endif
42 #define NET_PORT    10052
43 
44 // Timeout interval
45 #define T_TIMEOUT 30000
46 
47 // Client limit
48 #define MAX_CLIENTS   31
49 
50 // Level file
51 #define LEVEL_FILE  "openjazz.tmp"
52 
53 
54 // Class
55 
56 /// Networking
57 class Network {
58 
59 	public:
60 #ifdef USE_SDL_NET
61 		TCPsocket socket;
62 		TCPsocket clientSocket;
63 		IPaddress ipAddress;
64 		SDLNet_SocketSet socketset;
65 #endif
66 
67 		Network          ();
68 		~Network         ();
69 
70 		int  host        ();
71 		int  join        (char *address);
72 		int  accept      (int sock);
73 		void close       (int sock);
74 		int  send        (int sock, unsigned char *buffer);
75 		int  recv        (int sock, unsigned char *buffer, int length);
76 		bool isConnected (int sock);
77 		int  getError    ();
78 
79 };
80 
81 
82 // Variables
83 
84 EXTERN char    *netAddress; /// Server address
85 EXTERN Network *net;
86 
87 #endif
88 
89