1 | /********************************************************************** <BR>
|
---|
2 | This file is part of Crack dot Com's free source code release of
|
---|
3 | Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
|
---|
4 | information about compiling & licensing issues visit this URL</a>
|
---|
5 | <PRE> If that doesn't help, contact Jonathan Clark at
|
---|
6 | golgotha_source@usa.net (Subject should have "GOLG" in it)
|
---|
7 | ***********************************************************************/
|
---|
8 |
|
---|
9 | #ifndef I4_NET_PROTOCOL_HH
|
---|
10 | #define I4_NET_PROTOCOL_HH
|
---|
11 |
|
---|
12 | #include "string/string.hh"
|
---|
13 |
|
---|
14 | // The network protocol is the interface to all the network commands.
|
---|
15 | // Multiple network interfaces such as TCPIP and IPX can exsist at the same time
|
---|
16 | // and you don't really have to know which one you are using.
|
---|
17 |
|
---|
18 |
|
---|
19 | class i4_net_address; // defined in network/net_addr.hh
|
---|
20 | class i4_notifier_socket; // defined in network/net_find.hh
|
---|
21 | class i4_finder_socket; // defined in network/net_find.hh
|
---|
22 | class i4_net_socket; // defined in network/net_sock.hh
|
---|
23 | class i4_net_address; // defined in network/net_addr.hh
|
---|
24 |
|
---|
25 | enum i4_protocol_type { I4_TCPIP }; // this is the only kind we have support for right now
|
---|
26 |
|
---|
27 | enum i4_socket_type { I4_PACKETED_DATA, // data is sent in packets (i.e. udp)
|
---|
28 | I4_CONTINOUS_STREAM }; // data is seen as a continous stream
|
---|
29 |
|
---|
30 | class i4_net_protocol
|
---|
31 | {
|
---|
32 | public:
|
---|
33 | static i4_net_protocol *first; // protocols are kept in a list
|
---|
34 | i4_net_protocol *next;
|
---|
35 |
|
---|
36 | i4_net_protocol();
|
---|
37 |
|
---|
38 | virtual char *name() = 0; // for debugging
|
---|
39 | virtual i4_protocol_type type() = 0;
|
---|
40 |
|
---|
41 | // this creates a socket that will notify other clients that this server
|
---|
42 | // exsist if the create a finder socket.
|
---|
43 | virtual i4_notifier_socket *create_notifier_socket(int port,
|
---|
44 | const i4_const_str ¬ification_string) = 0;
|
---|
45 |
|
---|
46 | // this socket will look for other server on the poll_port
|
---|
47 | // implemented as spurious broadcast packets.
|
---|
48 | virtual i4_finder_socket *create_finder_socket(int poll_port, int listen_port) = 0;
|
---|
49 |
|
---|
50 | // for TCPIP this converts an internet name to an IP address
|
---|
51 | virtual i4_net_address *name_to_address(const i4_const_str &name) = 0;
|
---|
52 |
|
---|
53 | // try to make a connection to a remote server
|
---|
54 | virtual i4_net_socket *connect(i4_net_address *addr,
|
---|
55 | i4_socket_type type=I4_CONTINOUS_STREAM) = 0;
|
---|
56 |
|
---|
57 | // creates a socket that listens to a port, see network/net_sock.hh
|
---|
58 | virtual i4_net_socket *listen(int port,
|
---|
59 | i4_socket_type type=I4_CONTINOUS_STREAM) = 0;
|
---|
60 |
|
---|
61 | // timeout=0 is inifinity, returns number of sockets with events pending
|
---|
62 | virtual int select(int milli_sec_timeout) = 0;
|
---|
63 | };
|
---|
64 |
|
---|
65 | inline i4_net_protocol *i4_get_first_protocol() { return i4_net_protocol::first; }
|
---|
66 |
|
---|
67 |
|
---|
68 | i4_net_protocol *i4_get_typed_protocol(i4_protocol_type type=I4_TCPIP);
|
---|
69 |
|
---|
70 | #endif
|
---|