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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? theory.html

?? Beej的socket教材
?? HTML
字號:
<HTML><HEAD><TITLE>What is a socket?</TITLE><METANAME="GENERATOR"CONTENT="Modular DocBook HTML Stylesheet Version 1.70"><LINKREL="HOME"TITLE="Beej's Guide to Network Programming"HREF="index.html"><LINKREL="PREVIOUS"TITLE="Intro"HREF="intro.html"><LINKREL="NEXT"TITLE="structs and Data Handling"HREF="structs.html"><METAHTTP-EQUIV="Content-Type"CONTENT="text/html; charset=utf-8"></HEAD><BODYCLASS="sect1"BGCOLOR="#FFFFFF"TEXT="#000000"LINK="#0000FF"VLINK="#840084"ALINK="#0000FF"><DIVCLASS="NAVHEADER"><TABLESUMMARY="Header navigation table"WIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><THCOLSPAN="3"ALIGN="center">Beej's Guide to Network Programming</TH></TR><TR><TDWIDTH="10%"ALIGN="left"VALIGN="bottom"><AHREF="intro.html">Prev</A></TD><TDWIDTH="80%"ALIGN="center"VALIGN="bottom"></TD><TDWIDTH="10%"ALIGN="right"VALIGN="bottom"><AHREF="structs.html">Next</A></TD></TR></TABLE><HRALIGN="LEFT"WIDTH="100%"></DIV><DIVCLASS="sect1"><H1CLASS="sect1"><ANAME="theory">2. What is a socket?</A></H1><P>You hear talk of "sockets" all the time, and perhaps you arewondering just what they are exactly.  Well, they're this: a way tospeak to other programs using standard Unix file descriptors.</P><P>What?</P><P>Ok--you may have heard some Unix hacker state, "Jeez,<EM>everything</EM> in Unix is a file!"  What that personmay have been talking about is the fact that when Unix programs do anysort of I/O, they do it by reading or writing to a file descriptor.  Afile descriptor is simply an integer associated with an open file.  But(and here's the catch), that file can be a network connection, a FIFO, apipe, a terminal, a real on-the-disk file, or just about anything else.Everything in Unix <EM>is</EM> a file!  So when you want tocommunicate with another program over the Internet you're gonna do itthrough a file descriptor, you'd better believe it.</P><P>"Where do I get this file descriptor for network communication,Mr.  Smarty-Pants?" is probably the last question on your mind rightnow, but I'm going to answer it anyway: You make a call to the<TTCLASS="function">socket()</TT> system routine.  It returns the socketdescriptor, and you communicate through it using the specialized<TTCLASS="function">send()</TT> and <TTCLASS="function">recv()</TT>(<BCLASS="command"><AHREF="http://linux.com.hk/man/showman.cgi?manpath=/man/man2/send.2.inc"TARGET="_top">mansend</A></B>, <BCLASS="command"><AHREF="http://linux.com.hk/man/showman.cgi?manpath=/man/man2/recv.2.inc"TARGET="_top">man recv</A></B>) socketcalls.</P><P>"But, hey!" you might be exclaiming right about now.  "If it's afile descriptor, why in the name of Neptune can't I just use the normal<TTCLASS="function">read()</TT> and <TTCLASS="function">write()</TT> calls tocommunicate through the socket?"  The short answer is, "You can!"  Thelonger answer is, "You can, but <TTCLASS="function">send()</TT> and<TTCLASS="function">recv()</TT> offer much greater control over your datatransmission."</P><P>What next?  How about this: there are all kinds of sockets.  Thereare DARPA Internet addresses (Internet Sockets), path names on a localnode (Unix Sockets), CCITT X.25 addresses (X.25 Sockets that you cansafely ignore), and probably many others depending on which Unix flavoryou run.  This document deals only with the first: InternetSockets.</P><DIVCLASS="sect2"><H2CLASS="sect2"><ANAME="twotypes">2.1. Two Types of Internet Sockets</A></H2><P>What's this?  There are two types of Internet sockets?  Yes.Well, no.  I'm lying.  There are more, but I didn't want to scare you.I'm only going to talk about two types here.  Except for this sentence,where I'm going to tell you that "Raw Sockets" are also very powerfuland you should look them up.</P><P>All right, already.  What are the two types?  One is "StreamSockets"; the other is "Datagram Sockets", which may hereafter bereferred to as "<TTCLASS="constant">SOCK_STREAM</TT>" and"<TTCLASS="constant">SOCK_DGRAM</TT>", respectively.  Datagram sockets aresometimes called "connectionless sockets".  (Though they can be<TTCLASS="function">connect()</TT>'d if you really want.  See <AHREF="syscalls.html#connect"><TTCLASS="function">connect()</TT></A>, below.)</P><P>Stream sockets are reliable two-way connected communicationstreams.  If you output two items into the socket in the order "1, 2",they will arrive in the order "1, 2" at the opposite end.  They willalso be error free.  Any errors you do encounter are figments of yourown deranged mind, and are not to be discussed here.</P><P>What uses stream sockets?  Well, you may have heard of the<BCLASS="command">telnet</B> application, yes?  It uses stream sockets.All the characters you type need to arrive in the same order you typethem, right?  Also, web browsers use the HTTP protocol which uses streamsockets to get pages.  Indeed, if you telnet to a web site on port 80,and type "<TTCLASS="computeroutput">GET /</TT>", it'll dump the HTMLback at you!</P><P>How do stream sockets achieve this high level of data transmissionquality?  They use a protocol called "The Transmission ControlProtocol", otherwise known as "TCP" (see <AHREF="http://www.rfc-editor.org/rfc/rfc793.txt"TARGET="_top">RFC-793</A> for extremely detailed infoon TCP.)  TCP makes sure your data arrives sequentially and error-free.You may have heard "TCP" before as the better half of "TCP/IP" where"IP" stands for "Internet Protocol" (see <AHREF="http://www.rfc-editor.org/rfc/rfc791.txt"TARGET="_top">RFC-791</A>.)  IP deals primarily withInternet routing and is not generally responsible for dataintegrity.</P><P>Cool.  What about Datagram sockets?  Why are they calledconnectionless?  What is the deal, here, anyway?  Why are theyunreliable?  Well, here are some facts: if you send a datagram, it mayarrive.  It may arrive out of order.  If it arrives, the data within thepacket will be error-free.</P><P>Datagram sockets also use IP for routing, but they don't use TCP;they use the "User Datagram Protocol", or "UDP" (see <AHREF="http://www.rfc-editor.org/rfc/rfc768.txt"TARGET="_top">RFC-768</A>.)</P><P>Why are they connectionless?  Well, basically, it's because youdon't have to maintain an open connection as you do with stream sockets.You just build a packet, slap an IP header on it with destinationinformation, and send it out.  No connection needed.  They are generallyused for packet-by-packet transfers of information.  Sampleapplications: <BCLASS="command">tftp</B>, <BCLASS="command">bootp</B>,etc.</P><P>"Enough!" you may scream. "How do these programs even work ifdatagrams might get lost?!"  Well, my human friend, each has it's ownprotocol on top of UDP.  For example, the tftp protocol says that foreach packet that gets sent, the recipient has to send back a packet thatsays, "I got it!" (an "ACK" packet.)  If the sender of the originalpacket gets no reply in, say, five seconds, he'll re-transmit the packetuntil he finally gets an ACK.  This acknowledgment procedure is veryimportant when implementing <TTCLASS="constant">SOCK_DGRAM</TT>applications.</P></DIV><DIVCLASS="sect2"><H2CLASS="sect2"><ANAME="lowlevel">2.2. Low level Nonsense and Network Theory</A></H2><P>Since I just mentioned layering of protocols, it's time to talkabout how networks really work, and to show some examples of how<TTCLASS="constant">SOCK_DGRAM</TT> packets are built.  Practically, you canprobably skip this section.  It's good background, however.</P><DIVCLASS="figure"><ANAME="figure1"></A><P><B>Figure 1. Data Encapsulation.</B></P><DIVCLASS="mediaobject"><P><IMGSRC="dataencap.gif"ALT="[Encapsulated Protocols Diagram]"></IMG></P></DIV></DIV><P>Hey, kids, it's time to learn about <EM><AHREF="theory.html#figure1">DataEncapsulation</A></EM>!  This is very very important.  It's soimportant that you might just learn about it if you take the networkscourse here at Chico State <TTCLASS="computeroutput">;-)</TT>.Basically, it says this: a packet is born, the packet is wrapped("encapsulated") in a header (and rarely a footer) by the first protocol(say, the TFTP protocol), then the whole thing (TFTP header included) isencapsulated again by the next protocol (say, UDP), then again by thenext (IP), then again by the final protocol on the hardware (physical)layer (say, Ethernet).</P><P>When another computer receives the packet, the hardware strips theEthernet header, the kernel strips the IP and UDP headers, the TFTPprogram strips the TFTP header, and it finally has the data.</P><P>Now I can finally talk about the infamous <EM>LayeredNetwork Model</EM>.  This Network Model describes a system ofnetwork functionality that has many advantages over other models.  Forinstance, you can write sockets programs that are exactly the samewithout caring how the data is physically transmitted (serial, thinEthernet, AUI, whatever) because programs on lower levels deal with itfor you.  The actual network hardware and topology is transparent to thesocket programmer.</P><P>Without any further ado, I'll present the layers of the full-blownmodel.  Remember this for network class exams:</P><P>&#13;<P></P><UL><LI><P>Application</P></LI><LI><P>Presentation</P></LI><LI><P>Session</P></LI><LI><P>Transport</P></LI><LI><P>Network</P></LI><LI><P>Data Link</P></LI><LI><P>Physical</P></LI></UL></P><P>The Physical Layer is the hardware (serial, Ethernet, etc.).  TheApplication  Layer is just about as far from the physical layer as youcan imagine--it's the place where users interact with thenetwork.</P><P>Now, this model is so general you could probably use it as anautomobile repair guide if you really wanted to.  A layered model moreconsistent with Unix might be:</P><P>&#13;<P></P><UL><LI><P>Application Layer (<EM>telnet, ftp,etc.</EM>)</P></LI><LI><P>Host-to-Host Transport Layer (<EM>TCP,UDP</EM>)</P></LI><LI><P>Internet Layer (<EM>IP androuting</EM>)</P></LI><LI><P>Network Access Layer (<EM>Ethernet, ATM, orwhatever</EM>)</P></LI></UL></P><P>At this point in time, you can probably see how these layerscorrespond to the encapsulation of the original data.</P><P>See how much work there is in building a simple packet?  Jeez!And you have to type in the packet headers yourself using"<BCLASS="command">cat</B>"!  Just kidding.  All you have to do for streamsockets is <TTCLASS="function">send()</TT> the data out.  All you have to dofor datagram sockets is encapsulate the packet in the method of yourchoosing and <TTCLASS="function">sendto()</TT> it out.  The kernel buildsthe Transport Layer and Internet Layer on for you and the hardware doesthe Network Access Layer.  Ah, modern technology.</P><P>So ends our brief foray into network theory.  Oh yes, I forgot totell you everything I wanted to say about routing: nothing!  That'sright, I'm not going to talk about it at all.  The router strips thepacket to the IP header, consults its routing table, blah blah blah.Check out the <AHREF="http://www.rfc-editor.org/rfc/rfc791.txt"TARGET="_top">IP RFC</A> if youreally really care.  If you never learn about it, well, you'lllive.</P></DIV></DIV><DIVCLASS="NAVFOOTER"><HRALIGN="LEFT"WIDTH="100%"><TABLESUMMARY="Footer navigation table"WIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top"><AHREF="intro.html">Prev</A></TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="index.html">Home</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top"><AHREF="structs.html">Next</A></TD></TR><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top">Intro</TD><TDWIDTH="34%"ALIGN="center"VALIGN="top">&nbsp;</TD><TDWIDTH="33%"ALIGN="right"VALIGN="top"><TTCLASS="type">struct</TT>s and Data Handling</TD></TR></TABLE></DIV></BODY></HTML>

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩高清欧美激情| 久久99久久久欧美国产| 日韩三级在线观看| 成人精品国产一区二区4080| 五月婷婷另类国产| 国产精品久久久久9999吃药| 日韩一区二区三区在线视频| 91老司机福利 在线| 麻豆一区二区99久久久久| 亚洲你懂的在线视频| 久久久蜜桃精品| 7777精品伊人久久久大香线蕉超级流畅 | 欧美aaaaaa午夜精品| 亚洲色图视频免费播放| 久久精品一区二区三区不卡| 在线播放国产精品二区一二区四区 | 水野朝阳av一区二区三区| 国产精品久久久久久久久免费丝袜| 日韩色在线观看| 欧美人与禽zozo性伦| 91日韩在线专区| www.日韩大片| 懂色av一区二区三区免费看| 国精产品一区一区三区mba桃花| 婷婷综合久久一区二区三区| 亚洲主播在线播放| 亚洲欧洲精品一区二区精品久久久 | 欧美美女喷水视频| 色综合久久99| 91免费在线视频观看| 成人av综合一区| 丰满白嫩尤物一区二区| 国产99久久久久久免费看农村| 美女在线观看视频一区二区| 日韩成人精品在线观看| 日韩精品久久理论片| 视频一区视频二区中文| 午夜婷婷国产麻豆精品| 亚洲.国产.中文慕字在线| 亚洲国产精品一区二区久久| 亚洲一区二区三区自拍| 一区二区三区中文在线观看| 亚洲在线成人精品| 亚洲一区二区三区中文字幕| 亚洲成人动漫一区| 亚洲国产精品视频| 亚洲一区二区在线免费看| 亚洲国产视频一区二区| 亚洲第一成年网| 美女诱惑一区二区| 国产精品综合在线视频| 粉嫩av亚洲一区二区图片| www.欧美精品一二区| 色综合 综合色| 欧美精品一二三| 精品国产区一区| 欧美激情资源网| 亚洲黄色性网站| 日本亚洲视频在线| 国内精品伊人久久久久av影院| 丁香天五香天堂综合| 91国偷自产一区二区使用方法| 在线不卡欧美精品一区二区三区| 日韩一区二区电影网| 久久精品视频一区二区| 亚洲欧美福利一区二区| 亚洲mv大片欧洲mv大片精品| 激情五月婷婷综合| 波波电影院一区二区三区| 欧美吞精做爰啪啪高潮| 精品国产a毛片| 最新欧美精品一区二区三区| 亚洲h在线观看| 国产成人精品免费一区二区| 91黄色激情网站| 久久综合九色综合97婷婷女人| 亚洲人成网站精品片在线观看| 日日噜噜夜夜狠狠视频欧美人| 国产一区二区三区日韩| 91免费版在线| 精品免费国产一区二区三区四区| 亚洲色图20p| 久久草av在线| 色狠狠色狠狠综合| 制服丝袜av成人在线看| 欧美极品另类videosde| 日日夜夜一区二区| 成人动漫一区二区| 日韩一区二区三区视频在线观看| 中文字幕国产一区二区| 香蕉成人伊视频在线观看| 国产成人av一区二区| 在线视频一区二区三| 久久色成人在线| 亚洲成av人片在线| 成人精品鲁一区一区二区| 欧美老女人在线| 亚洲欧美综合网| 久久99精品久久久久久国产越南| 91免费版pro下载短视频| 久久婷婷成人综合色| 天堂一区二区在线| 91香蕉视频mp4| 久久综合色鬼综合色| 丝袜亚洲精品中文字幕一区| 91麻豆文化传媒在线观看| 久久一夜天堂av一区二区三区| 中文字幕一区二区三中文字幕| 裸体一区二区三区| 欧美日韩黄色一区二区| 亚洲欧美电影院| 成人av午夜电影| 久久免费看少妇高潮| 青椒成人免费视频| 欧美精品亚洲二区| 亚洲一区二区五区| 91国偷自产一区二区开放时间 | 国产成人免费av在线| 欧美大片在线观看| 蜜桃av噜噜一区| 欧美精品久久一区| 亚洲第一久久影院| 欧美系列亚洲系列| 一区二区欧美在线观看| 97久久超碰国产精品| 国产精品久久久久影院老司| 成人自拍视频在线| 欧美韩国一区二区| 国产精品自拍一区| 日韩精品一区二区在线| 免费在线观看不卡| 日韩欧美国产三级电影视频| 麻豆精品久久久| 精品福利在线导航| 久久99精品久久久久婷婷| 精品精品国产高清a毛片牛牛| 久久av资源网| 精品免费国产二区三区 | 成人精品一区二区三区四区| 国产精品美女久久福利网站| 国产成人在线电影| 欧美激情综合网| 一本色道久久综合亚洲aⅴ蜜桃| 亚洲视频一区二区免费在线观看| 91亚洲永久精品| 一区二区高清免费观看影视大全| 欧美午夜视频网站| 日本亚洲视频在线| 久久五月婷婷丁香社区| 成人小视频免费观看| 国产精品久久久久7777按摩| 99精品偷自拍| 午夜久久久久久久久| 欧美成人video| 高清视频一区二区| 一区二区三区日韩精品视频| 欧美三级视频在线| 久久精品国产亚洲一区二区三区| 久久久精品免费网站| 不卡的电影网站| 午夜一区二区三区视频| 精品国产人成亚洲区| 成人av电影免费在线播放| 一卡二卡三卡日韩欧美| 91精品国产一区二区人妖| 韩国精品一区二区| 国产精品久久久久一区| 欧美老人xxxx18| 国产宾馆实践打屁股91| 亚洲国产日韩精品| 精品福利一区二区三区免费视频| 成人短视频下载| 日本欧美一区二区三区乱码| 国产精品污污网站在线观看| 在线观看亚洲a| 国产麻豆精品在线| 亚洲激情欧美激情| 精品99一区二区三区| 色综合网色综合| 久久99日本精品| 亚洲蜜臀av乱码久久精品蜜桃| 51精品视频一区二区三区| 国产福利一区二区三区| 亚洲大尺度视频在线观看| 久久久久久久久久久久久夜| 欧洲一区在线观看| 国产在线精品视频| 夜夜嗨av一区二区三区中文字幕| 精品国产麻豆免费人成网站| 色网综合在线观看| 国产在线乱码一区二区三区| 亚洲一二三四区| 国产女主播一区| 日韩女优制服丝袜电影| 91久久国产综合久久| 国产成a人亚洲| 麻豆免费精品视频| 亚洲综合av网| 中文字幕成人av| 精品国产一区二区三区不卡|