annotate sources/headers/network.hpp @ 2:19227b0b7cc1

.h => .hpp for the headers added year 2008 to copyright notes renamed some functions for better meaning prepared parser module for rewriting added showHelp() function some code clean up
author Vlad Glagolev <enqlave@gmail.com>
date Mon, 21 Jan 2008 01:14:10 +0300
parents
children a7051ac7118b
rev   line source
2
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
1 /**
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
2 * network.hpp (2007-04-02)
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
3 *
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
4 * -- CABAL -- network header
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
5 *
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
6 * Copyright (c) 2007-2008 Vlad Glagolev <enqlave@gmail.com>
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
7 * All rights reserved.
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
8 *
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
9 * Permission to use, copy, modify, and distribute this software for any
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
10 * purpose with or without fee is hereby granted, provided that the above
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
11 * copyright notice and this permission notice appear in all copies.
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
12 *
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
13 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
14 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
15 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
16 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
17 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
18 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
19 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
20 */
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
21
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
22 #ifndef _NETWORK_HPP_
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
23 #define _NETWORK_HPP_
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
24
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
25 #include "core.hpp"
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
26
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
27 class Network {
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
28
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
29 public:
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
30 Network();
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
31 ~Network();
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
32
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
33 void sendMsg(string);
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
34 string receiveMsg();
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
35
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
36 int cs;
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
37
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
38 struct address_type {
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
39 int inet;
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
40 struct sockaddr_in sa;
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
41 #ifdef ENABLE_IPV6
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
42 struct sockaddr_in6 sa6;
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
43 #endif
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
44 } address;
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
45
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
46 bool socketClose();
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
47
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
48 bool hostResolve(pchar, address_type *, int inet = 0);
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
49 bool tcpActivate(int, pchar host = 0);
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
50 bool hostOpen();
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
51
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
52 int canRead(int);
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
53 int canWrite(int);
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
54
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
55 fd_set rs, ws;
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
56 timeval timeout;
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
57
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
58 bool connecting, connected;
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
59 };
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
60
19227b0b7cc1 .h => .hpp for the headers
Vlad Glagolev <enqlave@gmail.com>
parents:
diff changeset
61 #endif // _NETWORK_HPP_