comparison sources/headers/network.h @ 0:bafff9de2a76

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