• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

data/H03-May-2022-655559

doc/H03-May-2022-12,2549,754

libgnetwork/H03-May-2022-18,22811,772

po/H03-May-2022-23,24418,636

tests/H03-May-2022-1,7981,308

AUTHORSH A D27-Oct-200383 43

COPYINGH A D24-Dec-200425.8 KiB503418

ChangeLogH A D17-Feb-200555.6 KiB1,8391,458

FAQH A D16-Nov-20032.1 KiB4237

HACKINGH A D21-Apr-2003328 96

INSTALLH A D24-Dec-20049 KiB230175

Makefile.amH A D06-Jul-2004873 5343

Makefile.inH A D03-May-202220.4 KiB680583

NEWSH A D17-Feb-20053.9 KiB140110

READMEH A D28-Oct-20036.3 KiB208169

TODOH A D11-Dec-20031.6 KiB4636

aclocal.m4H A D08-Feb-2005267.1 KiB7,7286,856

compileH A D24-Dec-20043 KiB10854

config.guessH A D24-Dec-200442.2 KiB1,4421,245

config.h.inH A D08-Feb-20052.3 KiB9261

config.subH A D24-Dec-200430.5 KiB1,5531,412

configureH A D03-May-2022772.5 KiB24,75120,093

configure.inH A D08-Feb-20058.2 KiB348264

depcompH A D24-Dec-200413.5 KiB480304

gtk-doc.makeH A D24-Dec-20044.2 KiB152123

install-shH A D24-Dec-20047 KiB295169

intltool-extract.inH A D24-Dec-200413.6 KiB516406

intltool-merge.inH A D03-May-202233.3 KiB1,3161,059

intltool-update.inH A D24-Dec-200426.1 KiB1,053828

ltmain.shH A D24-Dec-2004179.6 KiB6,4275,058

missingH A D24-Dec-200410 KiB337263

mkinstalldirsH A D24-Dec-20041.9 KiB11285

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