Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > media > main-release > by-pkgid > 02424cba585f0a532f3fa58b2c5b6746 > files > 44

lib64gnet-2.0-devel-2.0.8-1mdv2008.1.x86_64.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>GNet Examples</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.72.0">
<link rel="start" href="index.html" title="GNet Network Library Reference Manual">
<link rel="up" href="index.html" title="GNet Network Library Reference Manual">
<link rel="prev" href="gnet-developers-async.html" title="Hiding blocking">
<link rel="next" href="gnet-examples-other.html" title="dnslookup, hash, hfetch, hostinfo, and SDR">
<meta name="generator" content="GTK-Doc V1.8 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
<link rel="chapter" href="gnet-overview.html" title="GNet Overview">
<link rel="chapter" href="gnet-developers.html" title="GNet for developers">
<link rel="chapter" href="gnet-examples.html" title="GNet Examples">
<link rel="chapter" href="libgnet-reference.html" title="GNet Library Reference">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle">
<td><a accesskey="p" href="gnet-developers-async.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td>&#160;</td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">GNet Network Library Reference Manual</th>
<td><a accesskey="n" href="gnet-examples-other.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr></table>
<div class="chapter" lang="en">
<div class="titlepage"><div><div><h2 class="title">
<a name="gnet-examples"></a>GNet Examples</h2></div></div></div>
<div class="toc"><dl>
<dt><span class="sect1"><a href="gnet-examples.html#gnet-examples-echo">echoclient and echoserver</a></span></dt>
<dt><span class="sect1"><a href="gnet-examples-other.html">dnslookup, hash, hfetch, hostinfo, and SDR</a></span></dt>
</dl></div>
<p>
      GNet comes with several example programs.  They are intended to
      be used by developers as examples of how to use GNet.  The
      example programs are in the examples directory that comes with
      the source code.
    </p>
<p>
      The tests in the tests directory also demonstrate to use several
      modules: MD5/SHA, InetAddr, IPv6, Pack/Unpack, and URI.
    </p>
<div class="sect1" lang="en">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="gnet-examples-echo"></a>echoclient and echoserver</h2></div></div></div>
<p>
	The echoclient connects to the echoserver and sends data it
	reads in from the user.  echoserver then sends it back and
	echoclient prints it out.  These programs demonstrate how to
	write a basic client and server.  There are three versions of
	the TCP echoclient and echoserver.  Each demonstrates a
	different method of using GNet: blocking, asynchronous, and
	object GConn/GServer.  There is also a blocking UDP example
	and a Unix sockets example.
      </p>
<p>
	echoclient/echoserver.  The blocking echoserver accepts a
	connection and reads and writes to the socket until the socket
	is closed.  No more than one echoclient can be connected at
	once.  A good, robust server wouldn't use this method, but it
	is suitable for many simple applications.
      </p>
<p>
	echoclient-async/echoserver-async.  The
	asynchronous server does not block while reading or writing to
	a socket or waiting for a connect.  Since it's never blocked,
	it can accept new connections when it isn't reading or writing
	to another socket.  The advantage of the this method is that
	multiple clients can be served at once.
      </p>
<p>
	echoclient-gconn/echoserver-gserver.
	echoclient-gconn uses GNet's GConn object.  echoserver-gserver
	uses GNet's GServer object.  GConn and GServer are high-level
	wrappers around GTcpSocket.  Using GConn and GServer is not as
	flexible as using GTcpSocket directly, but it is much easier
	and is flexible enough for most applications.
      </p>
<p>
	There is no example using threads.  If you would like to
	contribute one, please send it to us.
      </p>
</div>
</div>
</body>
</html>