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

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

?? tyt14fi.htm

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

<HEAD>

<TITLE>tyt14fi.htm</TITLE>

<LINK REL="ToC" HREF="index.htm" tppabs="http://www.mcp.com/817948800/0-672/0-672-30885-1/index.htm">

<LINK REL="Index" HREF="tppmsgs/msgs0.htm#3" tppabs="http://www.mcp.com/817948800/0-672/0-672-30885-1/htindex.htm">

<LINK REL="Next" HREF="tytxafi.htm" tppabs="http://www.mcp.com/817948800/0-672/0-672-30885-1/tytxafi.htm">

<LINK REL="Previous" HREF="tyt13fi.htm" tppabs="http://www.mcp.com/817948800/0-672/0-672-30885-1/tyt13fi.htm"></HEAD>

<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080"><A ID="I0" NAME="I0"></A>

<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="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>


<HR ALIGN=CENTER>

<P>

<UL>

<UL>

<UL>

<LI>

<A HREF="#E68E126" >Development of the Socket Programming Interface</A></LI>

<LI>

<A HREF="#E68E127" >Socket Services</A></LI>

<UL>

<LI>

<A HREF="#E69E178" >Transmission Control Block</A></LI>

<LI>

<A HREF="#E69E179" >Creating a Socket</A></LI>

<LI>

<A HREF="#E69E180" >Binding the Socket</A></LI>

<LI>

<A HREF="#E69E181" >Connecting to the Destination</A></LI>

<LI>

<A HREF="#E69E182" >The open Command</A></LI>

<LI>

<A HREF="#E69E183" >Sending Data</A></LI>

<LI>

<A HREF="#E69E184" >Receiving Data</A></LI>

<LI>

<A HREF="#E69E185" >Server Listening</A></LI>

<LI>

<A HREF="#E69E186" >Getting Status Information</A></LI>

<LI>

<A HREF="#E69E187" >Closing a Connection</A></LI>

<LI>

<A HREF="#E69E188" >Aborting a Connection</A></LI>

<LI>

<A HREF="#E69E189" >UNIX Forks</A></LI></UL>

<LI>

<A HREF="#E68E128" >Summary</A></LI>

<LI>

<A HREF="#E68E129" >Q&amp;A</A></LI>

<LI>

<A HREF="#E68E130" >Quiz</A></LI></UL></UL></UL>

<HR ALIGN=CENTER>

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

<H1 ALIGN=CENTER>

<CENTER>

<FONT SIZE=6 COLOR="#FF0000"><B>&#151; 14 &#151;</B>

<BR><B>The Socket Programming Interface</B></FONT></CENTER></H1>

<BR>

<P>Today I look at the last remaining aspect of TCP/IP this course covers: the socket interface for programming. This information is intended to convey the process needed to integrate an application with TCP/IP and as such involves some basic programming functions. It is not necessary to understand programming to understand this information. The functions involved in the socket programming interface help you understand the steps TCP/IP goes through when creating connections and sending data.

<BR>

<P>Understanding the socket interface is helpful even if you never intend to write a line of TCP/IP code, because all the applications you will work with use these principles and procedures. Debugging or troubleshooting a problem is much easier when you understand what is going on behind the user interface. Today I don't attempt to show the complete socket interface. Instead I deal only with the primary functions necessary to create and maintain a connection. This chapter is not intended to be a programming guide, either.

<BR>

<P>Because the original socket interface was developed for UNIX systems, today's text has a decidedly UNIX-based orientation. However, the same principles apply to most other operating systems that support TCP/IP.

<BR>

<BR>

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

<H3 ALIGN=CENTER>

<CENTER>

<FONT SIZE=5 COLOR="#FF0000"><B>Development of the Socket Programming Interface</B></FONT></CENTER></H3>

<BR>

<P>TCP/IP is fortunate because it has a well-defined application programming interface (API), which dictates how an application uses TCP/IP. This solves a basic problem that has occurred on many other communications protocols, which have several approaches to the same problem, each incompatible with the other. The TCP/IP API is portable (it works across all operating systems and hardware that support TCP/IP), language-independent (it doesn't matter which language you use to write the application), and relatively uncomplicated.

<BR>

<P>The Socket API was developed at the University of California at Berkeley as part of their BSD 4.1c UNIX version. Since then the API has been modified and enhanced but still retains its BSD flavor. Not to be outdone, AT&amp;T (BSD's rival in the UNIX market) introduced the Transport Layer Interface (TLI) for TCP and several other protocols. One of the strengths of the Socket API and TLI is that they were not developed exclusively for TCP/IP but are intended for use with several communications protocols. The Socket interface remains the most widespread API in current use, although several newer interfaces are being developed.

<BR>

<P>The basic structure of all socket programming commands lies with the unique structure of UNIX I/O. With UNIX, both input and output are treated as simple pipelines, where the input can be from anything and the output can go anywhere. The UNIX I/O system is sometimes referred to as the <I>open-read-write-close</I> system, because those are the steps that are performed for each I/O operation, whether it involves a file, a device, or a communications port.

<BR>

<P>Whenever a file is involved, the UNIX operating system gives the file a <I>file descriptor, </I>a small number that uniquely identifies the file. A program can use this file descriptor to identify the file at any time. (The same holds true for a device; the process is the same.) A file operation uses an open function to return the file descriptor, which is used for the read (transfer data to the user's process) or write (transfer data from the user process to the file) functions, followed by a close function to terminate the file operation. The open function takes a filename as an argument. The read and write functions use the file descriptor number, the address of the buffer in which to read or write the information, and the number of bytes involved. The close function uses the file descriptor. The system is easy to use and simple to work with.

<BR>

<P>TCP/IP uses the same idea, relying on numbers to uniquely identify an end point for communications (a socket). Whenever the socket number is used, the operating system can resolve the socket number to the physical connector. An essential difference between a file descriptor and a socket number is that the socket requires some functions to be performed prior to the establishment of the socket (such as initialization). In techno-speak, &quot;a file descriptor binds to a specific file or device when the open function is called, but the socket can be created without binding them to a specific destination at all (necessary for UDP), or bind them later (for TCP when the remote address is provided).&quot; The same open-read-write-close procedure is used with sockets.

<BR>

<P>The process was actually used literally with the first versions of TCP/IP. A special file called /dev/tcp was used as the device driver. The complexity added by networking made this approach awkward, though, so a library of special functions (the API) was developed. The essential steps of open, read, write, and close are still followed in the protocol API.

<BR>

<BR>

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

<H3 ALIGN=CENTER>

<CENTER>

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

<BR>

<P>There are three types of socket interfaces defined in the TCP/IP API. A socket can be used for TCP <I>stream communications, </I>in which a connection between two machines is created. It can be used for <I>UDP datagram </I><I>communications,</I> a connectionless method of passing information between machines using packets of a predefined format. Or it can be used as a <I>raw</I> datagram process, in which the datagrams bypass the TCP/UDP layer and go straight to IP. The latter type arises from the fact that the socket API was not developed exclusively for TCP/IP.

<BR>

<P>The presence of all three types of interfaces can lead to problems with some parameters that depend exclusively on the type of interface. You must always bear in mind whether TCP or UDP is used.

<BR>

<P>There are six basic communications commands that the socket API addresses through the TCP layer:

<BR>

<UL>

<LI>open: Establishes a socket

<BR></LI>

<BR>

<LI>send: Sends data to the socket

<BR></LI>

<BR>

<LI>receive: Receives data from a socket

<BR></LI>

<BR>

<LI>status: Obtains status information about a socket

<BR></LI>

<BR>

<LI>close: Terminates a connection

<BR></LI>

<BR>

<LI>abort: Cancels an operation and terminates the connection

<BR></LI>

<BR>

</UL>

<P>All six operations are logical and used as you would expect. The details for each step can be quite involved, but the basic operation remains the same. Many of the functions have been seen in previous days when dealing with specific protocols in some detail. Some of the functions (such as open) comprise several other functions that are available if necessary (such as establishing each end of the connection instead of both ends at once).

<BR>

<P>Despite the formal definition of the functions within the API specifications, no formal method is given for how to implement them. There are two logical choices: synchronous, or <I>blocking,</I> in which the application waits for the command to complete before continuing execution; and asynchronous, or <I>nonblocking,</I> in which the application continues executing while the API function is processed. In the latter case, a function call further in the application's execution can check the API functions' success and return codes.

<BR>

<P>The problem with the synchronous or blocking method is that the application must wait for the function call to complete. If timeouts are involved, this can cause a noticeable delay for the user.

<BR>

<BR>

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

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>Transmission Control Block</B></FONT></CENTER></H4>

<BR>

<P>The Transmission Control Block (TCB) is a complex data structure that contains details about a connection. The full TCB has over fifty fields in it. The exact layout and contents of the TCB are not necessary for today's material, but the existence of the TCB and the nature of the information it holds are key to the behavior of the socket interface.

<BR>

<BR>

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

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>Creating a Socket</B></FONT></CENTER></H4>

<BR>

<P>The API lets a user create a socket whenever necessary with a simple function call. The function requires the family of the protocol to be used with the socket (so the operating system knows which type of socket to assign and how to decode information), the type of communication required, and the specific protocol. Such a function call is written as follows:

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">socket(<I>family</I>, <I>type</I>, <I>protocol</I>)</FONT></PRE>

<P>The <I>family</I> of the protocol actually specifies how the addresses are interpreted. Examples of families are TCP/IP (coded as AF_INET), Apple's AppleTalk (AF_APPLETALK), and UNIX filesystems (AF_UNIX). The exact protocol within the family is specified as the protocol parameter. When used, it specifically indicates the type of service that is to be used.

<BR>

<P>The <I>type</I> parameter indicates the type of communications used. It can be a connectionless datagram service (coded as SOCK_DGRAM), a stream delivery service (SOCK_STREAM), or a raw type (SOCK_RAW). The result from the function call is an integer that can be assigned to a variable for further checking.

<BR>

<BR>

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

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>Binding the Socket</B></FONT></CENTER></H4>

<BR>

<P>Because a socket can be created without any binding to an address, there must be a function call to complete this process and establish the full connection. With the TCP/IP protocol, the socket function does not supply the local port number, the destination port, or the IP address of the destination. The bind function is called to establish the local port address for the connection.

<BR>

<P>Some applications (especially on a server) want to use a specific port for a connection. Other applications are content to let the protocol software assign a port. A specific port can be requested in the bind function. If it is available, the software allocates it and returns the port information. If the port cannot be allocated (it might be in use), a return code indicates an error in port assignment.

<BR>

<P>The bind function has the following format:

<BR>

<BR>

<PRE>

<FONT COLOR="#000080">bind(<I>socket</I>, <I>local_address</I>, <I>address_length</I>)</FONT></PRE>

<P><I>socket</I> is the integer number of the socket to which the bind is completed; <I>local_address</I> is the local address to which the bind is performed; and <I>address_length</I> is an integer that gives the length of the address in bytes. The address is not returned as a simple number but has the structure shown in Figure 14.1.

<BR>

<P><B><A HREF="14tyt01.gif" tppabs="http://www.mcp.com/817948800/0-672/0-672-30885-1/14tyt01.gif">Figure 14.1. Address structure used by the socket </B><B>API.</A></B>

<BR>

<P>The address data structure (which is called usually called sockaddr for <I>socket address</I>) has a 16-bit Address Family field that identifies the protocol family of the address. The entry in this field determines the format of the address in the following field (which might contain other information than the address, depending on how the protocol has defined the field). The Address field can be up to 14 bytes in length, although most protocols do not need this amount of space.

<BR>

<BLOCKQUOTE>

<BLOCKQUOTE>

<HR ALIGN=CENTER>

<BR>

<NOTE>

<IMG SRC="note.gif" tppabs="http://www.mcp.com/817948800/0-672/0-672-30885-1/note.gif" WIDTH = 75 HEIGHT = 46>The use of a data structure instead of a simple address has its roots in the UNIX operating system and the closely allied C programming language. The formal structure of the socket address enables C programs to use a union of structures for all possible address families. This saves a considerable amount of coding in applications.</NOTE>

<BR>

<HR ALIGN=CENTER>

</BLOCKQUOTE></BLOCKQUOTE>

<P>TCP/IP has a family address of 2, following which the Address field contains both a protocol port number (16 bits) and the IP address (32 bits). The remaining eight bytes are unused. This is shown in Figure 14.2. Because the address family defines how the Address field is decoded, there should be no problem with TCP/IP applications understanding the two pieces of information in the Address field.

<BR>

<P><B><A HREF="14tyt02.gif" tppabs="http://www.mcp.com/817948800/0-672/0-672-30885-1/14tyt02.gif">Figure 14.2. The address structure for TCP/IP.</A></B>

<BR>

<BR>

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

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>Connecting to the Destination</B></FONT></CENTER></H4>

<BR>

<P>After a local socket address and port number have been assigned, the destination socket can be connected. A one-ended connection is referred to as being in an <I>unconnected state, </I>whereas a two-ended (complete) connection is in a <I>connected state.</I> After a bind function, an unconnected state exists. To become connected, the destination socket must be added to complete the connection.

<BR>

<BLOCKQUOTE>

<BLOCKQUOTE>

<HR ALIGN=CENTER>

<BR>

<NOTE>

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美精品免费视频| 亚洲一区二区三区中文字幕在线| 中文字幕中文字幕在线一区| 亚洲国产精品一区二区www | 欧美一区二区三区在线电影 | 欧美日本国产视频| 国产91高潮流白浆在线麻豆| 欧洲人成人精品| 精品欧美一区二区三区精品久久| 日韩毛片高清在线播放| 麻豆国产精品777777在线| 日本一不卡视频| 91蜜桃免费观看视频| 欧美国产日韩一二三区| 久久99精品久久久久| 欧美丰满美乳xxx高潮www| 亚洲品质自拍视频网站| 不卡大黄网站免费看| 久久久国产精品午夜一区ai换脸| 亚洲第一福利视频在线| 色呦呦国产精品| 亚洲人午夜精品天堂一二香蕉| 国产成人福利片| 精品国产污污免费网站入口| 人妖欧美一区二区| 777色狠狠一区二区三区| 一区二区三区不卡视频| 91免费观看国产| 亚洲欧美综合另类在线卡通| 99热国产精品| 亚洲四区在线观看| 色综合天天综合色综合av | 国产精品乱码人人做人人爱 | 日韩精品欧美精品| 欧美日本一区二区在线观看| 一区二区三区在线免费视频| 91在线porny国产在线看| 日韩毛片视频在线看| 一本到不卡免费一区二区| 自拍偷拍欧美精品| 在线免费观看一区| 亚洲国产视频一区| 7777精品伊人久久久大香线蕉超级流畅 | 亚洲欧美另类久久久精品 | 亚洲成人精品一区二区| 在线一区二区三区四区五区 | 国产精品久久久久久久久图文区| 亚洲美女免费在线| 欧美午夜精品理论片a级按摩| 亚洲一区二三区| 欧美日韩精品免费| 美女视频黄a大片欧美| 欧美变态口味重另类| 国产一区二区电影| 国产精品美女一区二区在线观看| 色综合亚洲欧洲| 午夜不卡av在线| 久久久综合视频| 99久久久久免费精品国产| 亚洲一区二区三区影院| 欧美一区二区啪啪| 国产成人av资源| 亚洲精品成人在线| 日韩午夜在线观看视频| 成人av资源网站| 日韩精品一卡二卡三卡四卡无卡| 欧美不卡一二三| 97成人超碰视| 免费观看成人鲁鲁鲁鲁鲁视频| 久久久久久麻豆| 在线观看av一区| 看电视剧不卡顿的网站| 国产精品久久久久影院色老大| 欧美日韩在线三级| 国产精品一区二区久久不卡 | 色婷婷综合久久久中文字幕| 日韩精品免费视频人成| 亚洲国产精品ⅴa在线观看| 欧美伊人久久大香线蕉综合69| 色综合色狠狠综合色| 日韩av一区二区三区四区| 国产婷婷色一区二区三区四区| 日本久久电影网| 国内精品国产成人国产三级粉色| 亚洲欧美日韩电影| 久久精品视频一区二区| 欧美日韩国产另类一区| 99久久久久久99| 成人一区在线观看| 精品一区二区三区免费| 亚洲18影院在线观看| 中文字幕亚洲视频| 久久久亚洲国产美女国产盗摄 | 国产精品视频看| 欧美一区二区在线免费观看| 色域天天综合网| 国产成人综合亚洲91猫咪| 青青草原综合久久大伊人精品| 亚洲视频香蕉人妖| 中文字幕亚洲成人| 欧美高清在线精品一区| 欧美一级淫片007| 色吊一区二区三区| 狠狠色丁香久久婷婷综合_中 | 亚洲欧美日韩国产中文在线| 99久久亚洲一区二区三区青草| 亚洲成人777| 伊人开心综合网| 一区二区三区视频在线看| 亚洲欧美另类在线| 亚洲精品中文在线| 亚洲欧美精品午睡沙发| 综合在线观看色| 最好看的中文字幕久久| 综合av第一页| 亚洲欧美国产毛片在线| 亚洲黄色免费网站| 午夜视黄欧洲亚洲| 亚洲成人tv网| 日韩和欧美的一区| 美女网站在线免费欧美精品| 日韩激情中文字幕| 蜜桃av一区二区三区| 免费国产亚洲视频| 国产在线精品一区二区夜色 | 久久一区二区视频| 久久精品免视看| 一区二区中文视频| 亚洲精品v日韩精品| 亚洲第一会所有码转帖| 美女视频黄久久| 国产成人av电影| 色呦呦日韩精品| 91精品久久久久久蜜臀| 精品国产一区久久| 国产女人aaa级久久久级| 亚洲欧洲三级电影| 亚洲成人免费观看| 精品一区二区国语对白| 成人性视频免费网站| 91久久奴性调教| 欧美一级久久久久久久大片| 国产亚洲一区二区三区| 亚洲日本中文字幕区| 偷窥少妇高潮呻吟av久久免费| 久久不见久久见免费视频1| 色爱区综合激月婷婷| 欧美少妇一区二区| 欧美v日韩v国产v| 亚洲欧美怡红院| 免费观看日韩av| 97精品国产97久久久久久久久久久久 | 亚洲视频综合在线| 天天综合色天天| 成人av在线网站| 91精品国产一区二区三区| 国产亚洲欧美激情| 一二三四社区欧美黄| 国产一区二区久久| 在线视频观看一区| 久久人人97超碰com| 一区二区三区毛片| 国产99久久久国产精品潘金| 欧美一a一片一级一片| 国产欧美日韩麻豆91| 视频一区二区欧美| 99久久久久久| 久久精品网站免费观看| 日本免费新一区视频| 成人av网在线| ww久久中文字幕| 日本va欧美va精品发布| 91日韩精品一区| 国产婷婷色一区二区三区在线| 视频一区视频二区在线观看| av不卡免费电影| 久久美女艺术照精彩视频福利播放 | 国产视频一区在线观看| 日本三级亚洲精品| av男人天堂一区| 欧美国产97人人爽人人喊| 国产在线观看免费一区| 91精品欧美福利在线观看| 亚洲女人小视频在线观看| 国产盗摄视频一区二区三区| 欧美成人免费网站| 免费观看在线综合| 69堂精品视频| 日韩制服丝袜av| 日韩一区二区在线免费观看| 一级做a爱片久久| 91久久精品一区二区三| 日韩理论电影院| 色综合久久综合网97色综合 | 日本精品视频一区二区三区| 亚洲欧美在线视频观看| 白白色 亚洲乱淫| 国产精品亲子伦对白| 丁香啪啪综合成人亚洲小说 | 精品99999|