⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gnet-examples.html

📁 GNet是一个简单的网络库。它是目标定向的
💻 HTML
字号:
<HTML><HEAD><TITLE>GNet Examples</TITLE><METANAME="GENERATOR"CONTENT="Modular DocBook HTML Stylesheet Version 1.77+"><LINKREL="HOME"TITLE="GNet Network Library Reference Manual"HREF="book1.html"><LINKREL="PREVIOUS"TITLE="Other tips and tricks"HREF="gnet-developers-tips.html"><LINKREL="NEXT"TITLE="hfetch"HREF="hfetch.html"></HEAD><BODYCLASS="CHAPTER"BGCOLOR="#FFFFFF"TEXT="#000000"LINK="#0000FF"VLINK="#840084"ALINK="#0000FF"><DIVCLASS="NAVHEADER"><TABLEWIDTH="100%"BORDER="0"BGCOLOR="#000000"CELLPADDING="1"CELLSPACING="0"><TR><THCOLSPAN="4"ALIGN="center"><FONTCOLOR="#FFFFFF"SIZE="5">GNet Network Library Reference Manual</FONT></TH></TR><TR><TDWIDTH="25%"BGCOLOR="#C00000"ALIGN="left"><AHREF="gnet-developers-tips.html"><FONTCOLOR="#FFFFFF"SIZE="3"><B>&#60;&#60;&#60; Previous Page</B></FONT></A></TD><TDWIDTH="25%"BGCOLOR="#0000C0"ALIGN="center"><FONTCOLOR="#FFFFFF"SIZE="3"><B><AHREF="book1.html"><FONTCOLOR="#FFFFFF"SIZE="3"><B>Home</B></FONT></A></B></FONT></TD><TDWIDTH="25%"BGCOLOR="#00C000"ALIGN="center"><FONTCOLOR="#FFFFFF"SIZE="3"><B>&nbsp;</B></FONT></TD><TDWIDTH="25%"BGCOLOR="#C00000"ALIGN="right"><AHREF="hfetch.html"><FONTCOLOR="#FFFFFF"SIZE="3"><B>Next Page &#62;&#62;&#62;</B></FONT></A></TD></TR></TABLE></DIV><DIVCLASS="CHAPTER"><H1><ANAME="GNET-EXAMPLES"></A>GNet Examples</H1><DIVCLASS="TOC"><DL><DT><B>Table of Contents</B></DT><DT><AHREF="gnet-examples.html#ECHO">echoclient and echoserver</A></DT><DT><AHREF="hfetch.html">hfetch</A></DT><DT><AHREF="sdr.html">SDR</A></DT><DT><AHREF="tests.html">Various test files</A></DT></DL></DIV><P>      GNet comes with several example programs.  They are intented 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.  To build the examples, install GNet then go to      this directory and type <TTCLASS="USERINPUT"><B>make examples</B></TT>.  This      section describes what each of the example programs does.    </P><BRCLEAR="all"><DIVCLASS="SECT1"><H1CLASS="SECT1"><ANAME="ECHO"></A>echoclient and echoserver</H1><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 TCP-based client and server.  echoclient-udp and	echoserver-udp are the UDP equivalents.      </P><P>	There are two methods of writing an server demonstrated:	blocking and non-blocking.  The blocking methods 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>	The second method is the non-blocking method.  The 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	connects when it isn't reading or writing to another socket.	Really it could block a little bit on those reads or writes,	but since it only reads when there's something to be read and	writes when there's buffer space to write into, this is rare.      </P><P>	The advantage of the non-blocking method is that multiple	clients can be served at once.  It's generally the best method	to use.  We use the glib event loop and GIOChannels for this.      </P><P>	(There is also an experimental third object method that uses	the Conn and Server modules.  If you are adventurous, you can	use this method.  Note that these modules may be buggy and the	interfaces may change.)      </P><P>	Another method, not implemented yet, is to use threads.  The	advantage is that it's easier to code.  The disadvantage is	it's not as efficient on a single-processor machine or on a	machine that doesn't have a good threads implementation.  If	you feel like implementing this, please email us the code and	we will include it.      </P></DIV></DIV><DIVCLASS="NAVFOOTER"><BRCLEAR="all"><BR><TABLEWIDTH="100%"BORDER="0"BGCOLOR="#000000"CELLPADDING="1"CELLSPACING="0"><TR><TDWIDTH="25%"BGCOLOR="#C00000"ALIGN="left"><AHREF="gnet-developers-tips.html"><FONTCOLOR="#FFFFFF"SIZE="3"><B>&#60;&#60;&#60; Previous Page</B></FONT></A></TD><TDWIDTH="25%"BGCOLOR="#0000C0"ALIGN="center"><FONTCOLOR="#FFFFFF"SIZE="3"><B><AHREF="book1.html"><FONTCOLOR="#FFFFFF"SIZE="3"><B>Home</B></FONT></A></B></FONT></TD><TDWIDTH="25%"BGCOLOR="#00C000"ALIGN="center"><FONTCOLOR="#FFFFFF"SIZE="3"><B>&nbsp;</B></FONT></TD><TDWIDTH="25%"BGCOLOR="#C00000"ALIGN="right"><AHREF="hfetch.html"><FONTCOLOR="#FFFFFF"SIZE="3"><B>Next Page &#62;&#62;&#62;</B></FONT></A></TD></TR><TR><TDCOLSPAN="2"ALIGN="left"><FONTCOLOR="#FFFFFF"SIZE="3"><B>Other tips and tricks</B></FONT></TD><TDCOLSPAN="2"ALIGN="right"><FONTCOLOR="#FFFFFF"SIZE="3"><B>hfetch</B></FONT></TD></TR></TABLE></DIV></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -