source: golgotha/src/i4/network/net_prot.hh @ 608

Last change on this file since 608 was 80, checked in by Sam Hocevar, 15 years ago
  • Adding the Golgotha source code. Not sure what's going to be interesting in there, but since it's all public domain, there's certainly stuff to pick up.
File size: 2.9 KB
Line 
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
19class i4_net_address;             // defined in network/net_addr.hh
20class i4_notifier_socket;         // defined in network/net_find.hh
21class i4_finder_socket;           // defined in network/net_find.hh
22class i4_net_socket;              // defined in network/net_sock.hh
23class i4_net_address;             // defined in network/net_addr.hh
24
25enum i4_protocol_type { I4_TCPIP };   // this is the only kind we have support for right now
26
27enum 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
30class i4_net_protocol
31{
32public:
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 &notification_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
65inline i4_net_protocol *i4_get_first_protocol() { return i4_net_protocol::first; }
66
67
68i4_net_protocol *i4_get_typed_protocol(i4_protocol_type type=I4_TCPIP);
69
70#endif
Note: See TracBrowser for help on using the repository browser.