亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? tyt14fi.htm

?? 快速學習TCP/IP協議
?? HTM
?? 第 1 頁 / 共 3 頁
字號:

<P><I>length</I> is the number of entries in the iovector. The format of the iovector is the same as mentioned previously and shown in Figure 14.4.

<BR>

<P>The recv function also can be used with connected sockets. It has the format

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">recv(<I>socket</I>, <I>buffer_address</I>, <I>length</I>, <I>flags</I>)</FONT></PRE>

<P>which corresponds to the send function's arguments.

<BR>

<P>The recvfrom and recvmsg functions enable data to be read from an unconnected socket. Their formats include the sender's address:

<BR>

<PRE>

<FONT COLOR="#000080">recvfrom(<I>socket</I>, <I>buffer</I>_<I>address</I>, <I>length</I>, <I>flags</I>, <I>source</I>_<I>address</I>, <I>address</I>_<I>length</I>)

recvmsg(<I>socket</I>, <I>message</I>_<I>structure</I>, <I>flags</I>)</FONT></PRE>

<P>The message structure in the recvmsg function corresponds to the structure in sendmsg. (See Figure 14.3.)

<BR>

<BR>

<A ID="E69E185" NAME="E69E185"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>Server Listening</B></FONT></CENTER></H4>

<BR>

<P>A server application that expects clients to call in to it has to create a socket (using socket), bind it to a port (with bind), then wait for incoming requests for data. The listen function handles problems that could occur with this type of behavior by establishing a queue for incoming connection requests. The queue prevents bottlenecks and collisions, such as when a new request arrives before a previous one has been completely handled, or two requests arrive simultaneously.

<BR>

<P>The listen function establishes a buffer to queue incoming requests, thereby avoiding losses. The function lets the socket accept incoming connection requests, which are all sent to the queue for future processing. The function's format is

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">listen(<I>socket</I>, <I>queue_length</I>)</FONT></PRE>

<P>where <I>queue_length</I> is the size of the incoming buffer. If the buffer has room, incoming requests for connections are added to the buffer and the application can deal with them in the order of reception. If the buffer is full, the connection request is rejected.

<BR>

<P>After the server has used listen to set up the incoming connection request queue, the accept function is used to actually wait for a connection. The format of the function is

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">accept(<I>socket</I>, <I>address</I>, <I>length</I>)</FONT></PRE>

<P><I>socket</I> is the socket on which to accept requests; <I>address</I> is a pointer to a structure similar to Figure 14.1; and <I>length</I> is a pointer to an integer showing the length of the address.

<BR>

<P>When a connection request is received, the protocol places the address of the client in the memory location indicated by the address parameter, and the length of that address in the length location. It then creates a new socket that has the client and server connected together, sending back the socket description to the client. The socket on which the request was received remains open for other connection requests. This enables multiple requests for a connection to be processed, whereas if that socket was closed down with each connection request, only one client/server process could be handled at a time.

<BR>

<P>One possible special occurrence must be handled on UNIX systems. It is possible for a single process to wait for a connection request on multiple sockets. This reduces the number of processes that monitor sockets, thereby lowering the amount of overhead the machine uses. To provide for this type of process, the select function is used. The format of the function is

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">select(<I>num_desc</I>, <I>in_desc</I>, <I>out_desc</I>, <I>excep_desc</I>, <I>timeout</I>)</FONT></PRE>

<P><I>num_desc</I> is the number of sockets or descriptors that are monitored; <I>in_desc</I> and <I>out_desc</I> are pointers to a bit mask that indicates the sockets or file descriptors to monitor for input and output, respectively; <I>excep_desc</I> is a pointer to a bit mask that specifies the sockets or file descriptors to check for exception conditions; and <I>timeout</I> is a pointer to an integer that indicates how long to wait (a value of 0 indicates forever). To use the select function, a server creates all the necessary sockets first, then calls select to determine which ones are for input, output, and exceptions.

<BR>

<BR>

<A ID="E69E186" NAME="E69E186"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>Getting Status Information</B></FONT></CENTER></H4>

<BR>

<P>Several status functions are used to obtain information about a connection. They can be used at any time, although they are typically used to establish the integrity of a connection in case of problems or to control the behavior of the socket.

<BR>

<P>The status functions require the name of the local connection, and they return a set of information, which might include the local and remote socket names, local connection name, receive and send window states, number of buffers waiting for an acknowledgment, number of buffers waiting for data, and current values for the urgent state, precedence, security, and timeout variables. Most of this information is read from the Transmission Control Block (TCB). The format of the information and the exact contents vary slightly, depending on the implementation.

<BR>

<P>The function getsockopt enables an application to query the socket for information. The function format is

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">getsockopt(<I>socket</I>, <I>level</I>, <I>option_id</I>, <I>option_result</I>, <I>length</I>)</FONT></PRE>

<P><I>socket</I> is the number of the socket; <I>level</I> indicates whether the function refers to the socket itself or the protocol that uses it; <I>option_id</I> is a single integer that identifies the type of information requested; <I>option_result</I> is a pointer to a memory location where the function should place the result of the query; and <I>length</I> is the length of the result.

<BR>

<P>The corresponding setsockopt function lets the application set a value for the socket. The function's format is the same as getsockopt except that <I>option_result</I> points to the value that is to be set, and <I>length</I> is the length of the value.

<BR>

<P>Two functions provide information about the local address of a socket. The getpeername function returns the address of the remote end. The getsockname function returns the local address of a socket. They have the following formats:

<BR>

<PRE>

<FONT COLOR="#000080">getpeername(<I>socket</I>, <I>destination</I>_<I>address</I>, <I>address</I>_<I>length</I>)

getsockname(<I>socket</I>, <I>local_address</I>, <I>address_length</I>)</FONT></PRE>

<P>The addresses in both functions are pointers to a structure of the format shown in Figure 14.1.

<BR>

<P>Two host name functions for BSD UNIX are gethostname and sethostname, which enable an application to obtain the name of the host and set the host name (if permissions allow). Their formats are as follows:

<BR>

<PRE>

<FONT COLOR="#000080">sethostname(<I>name</I>, <I>length</I>)

gethostname(<I>name</I>, <I>length</I>)</FONT></PRE>

<P>The <I>name</I> is the address of an array that holds the name, and the <I>length</I> is an integer that gives the name's length.

<BR>

<P>A similar set of functions provides for domain names. The functions setdomainname and getdomainname enable an application to obtain or set the domain names. Their formats are

<BR>

<PRE>

<FONT COLOR="#000080">setdomainname(<I>name</I>, <I>length</I>)

getdomainname(<I>name</I>, <I>length</I>)</FONT></PRE>

<P>The parameters are the same as with the sethostname and gethostname functions, except for the format of the name (which reflects domain name format).

<BR>

<BR>

<A ID="E69E187" NAME="E69E187"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>Closing a Connection</B></FONT></CENTER></H4>

<BR>

<P>The close function closes a connection. It requires only the local connection name to complete the process. It also takes care of the TCB and releases any variable created by the connection. No output is generated.

<BR>

<P>The close function is initiated with the call

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">close(<I>socket</I>)</FONT></PRE>

<P>where the socket name is required. If an application terminates abnormally, the operating system closes all sockets that were open prior to the termination.

<BR>

<BR>

<A ID="E69E188" NAME="E69E188"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>Aborting a Connection</B></FONT></CENTER></H4>

<BR>

<P>The abort function instructs TCP to discard all data that currently resides in send and receive buffers and close the connection. It takes the local connection name as input. No output is generated. This function can be used in case of emergency shutdown routines, or in case of a fatal failure of the connection or associated software.

<BR>

<P>The abort function is usually implemented by the close() call, although some special instructions might be available with different implementations.

<BR>

<BR>

<A ID="E69E189" NAME="E69E189"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>UNIX Forks</B></FONT></CENTER></H4>

<BR>

<P>UNIX has two system calls that can affect sockets: fork and exec. Both are frequently used by UNIX developers because of their power. (In fact, forks are one of the most powerful tools UNIX offers, and one that most other operating systems lack.) For simplicity, I deal with the two functions as though they perform the same task.

<BR>

<P>A fork call creates a copy of the existing application as a new process and starts executing it. The new process has all the original's file descriptors and socket information. This can cause a problem if the application programmer didn't take into account the fact that two (or more) processes try to use the same socket (or file) simultaneously. Therefore, applications that can fork have to take into account potential conflicts and code around them by checking the status of shared sockets.

<BR>

<P>The operating system itself keeps a table of each socket and how many processes have access to it. An internal counter is incremented or decremented with each process's open or close function call for the socket. When the last process using a socket is terminated, the socket is permanently closed. This prevents one forked process from closing a socket when its original is still using it.

<BR>

<BR>

<A ID="E68E128" NAME="E68E128"></A>

<H3 ALIGN=CENTER>

<CENTER>

<FONT SIZE=5 COLOR="#FF0000"><B>Summary</B></FONT></CENTER></H3>

<BR>

<P>Today you have seen the basic functions performed by the socket API during establishment of a TCP or UDP call. You have also seen the functions that are available to application programmers. Although the treatment has been at a high level, you should be able to see that working with sockets is not a complex, confusing task. Indeed, socket programming is surprisingly easy once you have tried it.

<BR>

<P>Not everyone wants to write TCP or UDP applications, of course. However, understanding the basics of the socket API helps in understanding the protocol and troubleshooting. If you are interested in programming sockets, one of the best books on the subject is <I>UNIX Network </I><I>Programming, </I>by W. Richard Stevens (Macmillan).

<BR>

<BR>

<A ID="E68E129" NAME="E68E129"></A>

<H3 ALIGN=CENTER>

<CENTER>

<FONT SIZE=5 COLOR="#FF0000"><B>Q&amp;A</B></FONT></CENTER></H3>

<BR>

<P><B>What is the socket interface used for?</B>

<BR>

<P>The socket interface enables you to write applications that make optimal use of the TCP/IP family of protocols. Without it, you would need another layer of application to translate your program's calls to TCP/IP calls.

<BR>

<P><B>What is the difference between blocking and nonblocking functions?</B>

<BR>

<P>A blocking function waits for the function to terminate before enabling the application to continue. A nonblocking function enables the application to continue executing while the function is performed. Both have important uses in applications.

<BR>

<P><B>What does binding do?</B>

<BR>

<P>Binding makes a logical connection between a socket and the application. Without it, the application couldn't access the socket.

<BR>

<P><B>What happens when an active </B><B>open</B><B> command is executed?</B>

<BR>

<P>An active open command creates a socket and binds it, then issues a connect call to identify the IP address and port. The active open command then tries to establish communications.

<BR>

<P><B>What is the difference between an </B><B>abort</B><B> and a </B><B>close</B><B> operation?</B>

<BR>

<P>A close operation closes a connection. An abort abandons whatever communications are currently underway and closes the connection. With an abort, any information in receive buffers is discarded.

<BR>

<BR>

<A ID="E68E130" NAME="E68E130"></A>

<H3 ALIGN=CENTER>

<CENTER>

<FONT SIZE=5 COLOR="#FF0000"><B>Quiz</B></FONT></CENTER></H3>

<BR>

<OL>

<LI>What are the six basic socket commands?

<BR></LI>

<BR>

<LI>A Transmission Control Block performs what function?

<BR></LI>

<BR>

<LI>What is the difference between an unspecified passive open and a fully specified passive open?

<BR></LI>

<BR>

<LI>What command displays status information about a socket?

<BR></LI>

<BR>

<LI>What is a fork?

<BR></LI>

<BR>

</OL>

<P><P ALIGN=CENTER>

<A HREF="tyt13fi.htm" tppabs="http://www.mcp.com/817948800/0-672/0-672-30885-1/tyt13fi.htm" TARGET="_self"><IMG SRC="blanprev.gif" tppabs="http://www.mcp.com/817948800/0-672/0-672-30885-1/blanprev.gif" WIDTH = 37 HEIGHT = 37 BORDER = 0 ALT="Previous Page"></A>

<A HREF="#I0" TARGET="_self"><IMG SRC="blantop.gif" tppabs="http://www.mcp.com/817948800/0-672/0-672-30885-1/blantop.gif" WIDTH = 37 HEIGHT = 37 BORDER = 0 ALT="Page Top"></A>

<A HREF="index.htm" tppabs="http://www.mcp.com/817948800/0-672/0-672-30885-1/index.htm" TARGET="_self"><IMG SRC="blantoc.gif" tppabs="http://www.mcp.com/817948800/0-672/0-672-30885-1/blantoc.gif" WIDTH = 37 HEIGHT = 37 BORDER = 0 ALT="TOC"></A>

<A HREF="tytxafi.htm" tppabs="http://www.mcp.com/817948800/0-672/0-672-30885-1/tytxafi.htm" TARGET="_self"><IMG SRC="blannext.gif" tppabs="http://www.mcp.com/817948800/0-672/0-672-30885-1/blannext.gif" WIDTH = 37 HEIGHT = 37 BORDER = 0 ALT="Next Page"></A>




</BODY></HTML>

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
麻豆精品国产91久久久久久| 日韩不卡在线观看日韩不卡视频| 高潮精品一区videoshd| 中文字幕中文字幕一区二区| 欧美日韩一区国产| 久久不见久久见免费视频1| 国产精品国产三级国产aⅴ中文 | 亚洲一区二区三区在线看| 欧美一区二区在线免费观看| 国产一区二三区| 亚洲精品欧美在线| 久久久亚洲精品一区二区三区| 色婷婷综合久色| 精品一区二区三区欧美| 亚洲精品免费一二三区| 久久看人人爽人人| 欧美亚洲愉拍一区二区| 成人美女视频在线看| 日韩av高清在线观看| 亚洲视频一区二区在线| 精品对白一区国产伦| 欧美亚洲日本一区| 精品一区二区在线免费观看| 一区二区三区四区视频精品免费| 久久女同精品一区二区| 777午夜精品视频在线播放| 99久久婷婷国产综合精品电影| 日韩专区一卡二卡| 自拍偷自拍亚洲精品播放| 26uuu国产日韩综合| 91精品国产色综合久久不卡电影 | 在线视频一区二区三| 91网上在线视频| 99国产欧美另类久久久精品| 大桥未久av一区二区三区中文| 国产在线播精品第三| 国产一区在线看| 国产成人综合亚洲91猫咪| 精品一区二区影视| 国产在线不卡一区| 国产乱妇无码大片在线观看| 国产精品一区免费在线观看| 国产真实乱对白精彩久久| 国产精品一区二区黑丝| 丰满少妇在线播放bd日韩电影| 国产成人高清视频| 成人免费高清视频| 色综合色综合色综合 | 欧美日韩国产综合一区二区三区| 在线观看国产一区二区| 欧美日韩日日夜夜| 欧美一区二区三区视频在线| 日韩一级片在线观看| 久久影院电视剧免费观看| 国产色婷婷亚洲99精品小说| 国产精品视频一二三| 亚洲精品日韩专区silk| 日韩在线卡一卡二| 久久国产成人午夜av影院| 国产成人在线视频免费播放| 91亚洲国产成人精品一区二区三 | 91亚洲精品一区二区乱码| 欧亚洲嫩模精品一区三区| 欧美日韩国产大片| 久久久综合精品| 亚洲欧美自拍偷拍色图| 午夜精品在线看| 激情成人午夜视频| 91小视频在线| 欧美精品乱码久久久久久按摩| 精品少妇一区二区三区日产乱码 | 经典三级视频一区| 99精品国产99久久久久久白柏| 欧美少妇xxx| 精品欧美乱码久久久久久1区2区| 国产色91在线| 亚洲国产精品天堂| 国产激情偷乱视频一区二区三区| 色爱区综合激月婷婷| 日韩一级视频免费观看在线| 国产精品伦理一区二区| 日韩电影在线观看网站| 大桥未久av一区二区三区中文| 欧美亚洲国产bt| www日韩大片| 亚洲福利一区二区| 国产成人av电影| 欧美精品v国产精品v日韩精品| 久久精品亚洲精品国产欧美kt∨| 一区二区三区国产| 国产剧情一区二区| 欧美老年两性高潮| 亚洲天堂精品视频| 久久99精品久久久久久| 欧洲一区在线观看| 国产精品美女久久久久av爽李琼 | 国产一区在线观看麻豆| 欧美性受xxxx黑人xyx性爽| 久久人人超碰精品| 日本三级亚洲精品| 欧美性大战xxxxx久久久| 国产精品少妇自拍| 国产综合久久久久影院| 欧美日韩在线播放| 亚洲女与黑人做爰| 成人性视频免费网站| 日韩午夜小视频| 亚洲成人免费视频| 色婷婷精品大在线视频| 国产婷婷色一区二区三区| 麻豆一区二区在线| 欧美日韩国产一级| 亚洲精品欧美综合四区| 成人黄色电影在线| 久久精品日产第一区二区三区高清版| 亚洲二区视频在线| 在线观看av不卡| 亚洲欧美精品午睡沙发| 成人三级伦理片| 国产欧美日产一区| 国产91在线|亚洲| 久久久www免费人成精品| 精品一区二区av| 日韩一区二区三区在线视频| 水蜜桃久久夜色精品一区的特点| 一本久道中文字幕精品亚洲嫩| 国产精品欧美一区喷水| 风间由美一区二区av101| 久久噜噜亚洲综合| 国产成人一区在线| 欧美国产欧美亚州国产日韩mv天天看完整 | 欧亚一区二区三区| 亚洲午夜私人影院| 91国产免费观看| 国产精品性做久久久久久| 精品久久五月天| 久久99久久精品欧美| 精品福利一区二区三区免费视频| 精品在线一区二区三区| 26uuu成人网一区二区三区| 久久国产尿小便嘘嘘| 91精品国产欧美一区二区成人| 日韩和欧美一区二区三区| 6080国产精品一区二区| 日本91福利区| 日韩一级二级三级| 国产麻豆午夜三级精品| 欧美极品xxx| 91麻豆文化传媒在线观看| 亚洲欧美日韩成人高清在线一区| 91蝌蚪porny| 亚瑟在线精品视频| 日韩午夜电影av| 国产传媒日韩欧美成人| 亚洲欧洲综合另类| 欧美日韩国产综合久久| 久久99热国产| 国产日韩欧美不卡在线| 91在线观看美女| 五月天精品一区二区三区| 欧美成人官网二区| 成人禁用看黄a在线| 一区二区成人在线| 6080yy午夜一二三区久久| 国产麻豆日韩欧美久久| 亚洲视频每日更新| 欧美喷水一区二区| 国产精品99久久久久久有的能看| 1区2区3区欧美| 91精品国产乱码久久蜜臀| 国产精品一二三四区| 一区二区三区在线播放| 日韩美女在线视频| 99久久久久久| 蜜桃av噜噜一区二区三区小说| 国产精品女主播av| 制服.丝袜.亚洲.另类.中文| 国产69精品久久777的优势| 亚洲电影欧美电影有声小说| 2024国产精品| 欧美日韩一区在线观看| 丁香另类激情小说| 日韩高清不卡一区二区| 国产精品久久久久久亚洲伦| 91精品欧美久久久久久动漫| 成人av电影免费在线播放| 日韩精品欧美精品| 中文字幕日韩一区| 精品人在线二区三区| 欧洲一区二区av| 成人爽a毛片一区二区免费| 日本最新不卡在线| 亚洲精品国产成人久久av盗摄| 精品久久国产老人久久综合| 91精彩视频在线观看| 国产成人av电影在线| 欧美aⅴ一区二区三区视频| 一区二区在线观看视频| 久久久久九九视频| 日韩三级电影网址|