|
Name |
|
Date |
Size |
#Lines |
LOC |
| .. | | 03-May-2022 | - |
| data/ | H | 03-May-2022 | - | 655 | 559 |
| doc/ | H | 03-May-2022 | - | 12,254 | 9,754 |
| libgnetwork/ | H | 03-May-2022 | - | 18,228 | 11,772 |
| po/ | H | 03-May-2022 | - | 23,244 | 18,636 |
| tests/ | H | 03-May-2022 | - | 1,798 | 1,308 |
| AUTHORS | H A D | 27-Oct-2003 | 83 | 4 | 3 |
| COPYING | H A D | 24-Dec-2004 | 25.8 KiB | 503 | 418 |
| ChangeLog | H A D | 17-Feb-2005 | 55.6 KiB | 1,839 | 1,458 |
| FAQ | H A D | 16-Nov-2003 | 2.1 KiB | 42 | 37 |
| HACKING | H A D | 21-Apr-2003 | 328 | 9 | 6 |
| INSTALL | H A D | 24-Dec-2004 | 9 KiB | 230 | 175 |
| Makefile.am | H A D | 06-Jul-2004 | 873 | 53 | 43 |
| Makefile.in | H A D | 03-May-2022 | 20.4 KiB | 680 | 583 |
| NEWS | H A D | 17-Feb-2005 | 3.9 KiB | 140 | 110 |
| README | H A D | 28-Oct-2003 | 6.3 KiB | 208 | 169 |
| TODO | H A D | 11-Dec-2003 | 1.6 KiB | 46 | 36 |
| aclocal.m4 | H A D | 08-Feb-2005 | 267.1 KiB | 7,728 | 6,856 |
| compile | H A D | 24-Dec-2004 | 3 KiB | 108 | 54 |
| config.guess | H A D | 24-Dec-2004 | 42.2 KiB | 1,442 | 1,245 |
| config.h.in | H A D | 08-Feb-2005 | 2.3 KiB | 92 | 61 |
| config.sub | H A D | 24-Dec-2004 | 30.5 KiB | 1,553 | 1,412 |
| configure | H A D | 03-May-2022 | 772.5 KiB | 24,751 | 20,093 |
| configure.in | H A D | 08-Feb-2005 | 8.2 KiB | 348 | 264 |
| depcomp | H A D | 24-Dec-2004 | 13.5 KiB | 480 | 304 |
| gtk-doc.make | H A D | 24-Dec-2004 | 4.2 KiB | 152 | 123 |
| install-sh | H A D | 24-Dec-2004 | 7 KiB | 295 | 169 |
| intltool-extract.in | H A D | 24-Dec-2004 | 13.6 KiB | 516 | 406 |
| intltool-merge.in | H A D | 03-May-2022 | 33.3 KiB | 1,316 | 1,059 |
| intltool-update.in | H A D | 24-Dec-2004 | 26.1 KiB | 1,053 | 828 |
| ltmain.sh | H A D | 24-Dec-2004 | 179.6 KiB | 6,427 | 5,058 |
| missing | H A D | 24-Dec-2004 | 10 KiB | 337 | 263 |
| mkinstalldirs | H A D | 24-Dec-2004 | 1.9 KiB | 112 | 85 |
README
1GNetwork Library
2
31. OVERVIEW:
4================================================================================
5GNetwork is a networking wrapper written in pure C against the Glib/GObject
6object framework.
7
8Requires:
9 GLib 2.3+ with thread support
10 GConf 2.0
11Optional SSL support:
12 GNUTLS 0.7 (recommended) or OpenSSL 0.9.6.
13
14The intention here is to provide a useful and easy-to-develop-against sockets
15wrapper for GNOME2 & GTK+ 2.0 programs which require TCP/IP connection
16capabilities. It can be used by programs which do not use GNOME or GTK+ anyways,
17however. It is NOT recommended or intended for high-load server situations,
18just user applications which need TCP/IP networking. Proxies are supported
19completely transparently, using the same settings as gnome-vfs.
20
21
222. BUGS:
23================================================================================
24Bugs can be reported at http://bugzilla.gnome.org/, against the libgnetwork
25module: http://bugzilla.gnome.org/enter_bug.cgi?product=libgnetwork
26
27
283. OBJECTS:
29================================================================================
30GNetwork provides the following interfaces and interfaces:
31
32 GNetworkConnection
33 +- GNetworkSslConnection
34 | +- GNetworkTcpConnection
35 +- GNetworkUnixConnection
36 +- GNetworkUdpConnection
37 GNetworkServer
38 +- GNetworkTcpServer
39 +- GNetworkUdpServer
40 +- GNetworkUnixServer
41
42These are either GObjects or GInterfaces.
43
443.1 GNetworkConnection:
45-----------------------
46The GNetworkConnection interface is an interface which wraps the standard system
47methods for handling outgoing socket connections.
48
493.1.1 GNetworkSslConnection:
50-----------------------
51The GNetworkSslConnection interface is a an add-on interface to
52GNetworkConnection for objects which want a standard means to access optional
53SSL support.
54
553.1.1.1 GNetworkTcpConnection:
56----------------------------
57The GNetworkTcpConnection object implements the GNetworkConnection interface
58for standard TCP/IP sockets, and the GNetworkSslConnection interface to access
59optional SSL support.
60
613.1.2 GNetworkUdpConnection:
62----------------------------
63The GNetworkUdpConnection object implements the GNetworkConnection interface
64for UDP (connection-less) sockets (not implemented yet).
65
663.1.3 GNetworkUnixConnection:
67----------------------------
68The GNetworkUnixConnection object implements the GNetworkConnection interface
69for standard UNIX domain sockets (not implemented yet).
70
713.2 GNetworkServer:
72-------------------
73The GNetworkServer interface is a interface which wraps the standard system
74methods for handling incoming socket connections. Implementations must create
75GNetworkConnection objects as needed to handle incoming connections.
76
773.2.1 GNetworkTcpServer:
78------------------------
79The GNetworkTcpServer object is an implementation of the GNetworkServer
80interface for standard TCP/IP sockets, including optional SSL support.
81
823.2.2 GNetworkUdpConnection:
83----------------------------
84The GNetworkUdpConnection object implements the GNetworkConnection interface
85for UDP (connection-less) sockets (not implemented yet).
86
873.2.3 GNetworkUnixConnection:
88----------------------------
89The GNetworkUnixConnection object implements the GNetworkConnection interface
90for standard UNIX domain sockets (not implemented yet).
91
92
93
94
95
964. Simple Examples:
97================================================================================
98
994.1 GNetworkTcpConnection:
100--------------------------
101Example connecting to port 80 of localhost without SSL:
102
103 #define HOST "localhost"
104
105 /* A GFunc to be added with g_idle_add, that is, the GMainLoop should've
106 already been started by the time this function is called. */
107 gboolean
108 do_tcp_connection (gpointer data)
109 {
110 GObject *connection;
111
112 connection = gnetwork_tcp_connection_new (HOST, 80, GNETWORK_TCP_PROXY_HTTP,
113 FALSE);
114 g_signal_connect (connection, "notify::tcp-status", status_cb, NULL);
115 g_signal_connect (connection, "error", error_cb, NULL);
116 g_signal_connect (connection, "received", recv_cb, NULL);
117 g_signal_connect (connection, "sent", sent_cb, NULL);
118 gnetwork_connection_open (GTCP_CONNECTION (connection));
119
120 return FALSE;
121 }
122
123 void
124 status_cb (GObject *connection, GParamSpec *pspec, gpointer user_data)
125 {
126 GNetworkTcpConnectionStatus status;
127 gchar *str;
128
129 status = gnetwork_tcp_connection_get_tcp_status (GNETWORK_TCP_CONNECTION
130 (connection));
131
132 switch (status)
133 {
134 case GNETWORK_TCP_CONNECTION_CLOSING:
135 g_message ("Closing connection.");
136 break;
137 case GNETWORK_TCP_CONNECTION_CLOSED:
138 g_message ("Connection closed.");
139 break;
140 case GNETWORK_TCP_CONNECTION_LOOKUP:
141 g_message ("Looking up host: %s.", HOST);
142 break;
143 case GNETWORK_TCP_CONNECTION_OPENING:
144 g_message ("Contacting host");
145 break;
146 case GNETWORK_TCP_CONNECTION_PROXYING:
147 str = gnetwork_tcp_proxy_get_host (GNETWORK_TCP_PROXY_HTTP);
148 g_message ("Traversing proxy: %s.", str);
149 g_free (str);
150 break;
151 case GNETWORK_TCP_CONNECTION_AUTHENTICATING:
152 /* We're not using SSL */
153 break;
154 case GNETWORK_TCP_CONNECTION_OPEN:
155 g_message ("The connection with %s is open.", HOST);
156 gnetwork_connection_send (GNETWORK_CONNECTION (connection),
157 "HTTP/1.1\r\nGET /index.html\r\n\r\n", -1);
158 break;
159
160 default:
161 g_assert_not_reached ();
162 break;
163 }
164 }
165
166 void
167 recv_cb (GNetworkConnection *connection, gconstpointer data, gulong length,
168 gpointer user_data)
169 {
170 g_message ("Recieved Data: '%s'", (gchar *) data);
171 }
172
173 void
174 send_cb (GNetworkConnection *connection, gconstpointer data, gulong length,
175 gpointer user_data)
176 {
177 g_message ("Sent Data: '%s'", (gchar *) data);
178 }
179
180 void
181 error_cb (GNetworkConnection *connection, GError *error, gpointer user_data)
182 {
183 switch (error->domain)
184 {
185 case G_IO_CHANNEL_ERROR:
186 g_print ("IO Error: ");
187 break;
188 case GNETWORK_CONNECTION_ERROR:
189 g_print ("Connection Error: ");
190 break;
191 case GNETWORK_TCP_PROXY_ERROR:
192 g_print ("Proxy Error: ");
193 break;
194 case GNETWORK_SSL_ERROR:
195 case GNETWORK_SSL_CERT_ERROR:
196 /* We're not using SSL */
197 return;
198 break;
199
200 default:
201 g_assert_not_reached ();
202 break;
203 }
204
205 g_print ("%s\n", error->message);
206 }
207
208