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

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

?? library_15.html

?? Glibc的中文手冊
?? HTML
?? 第 1 頁 / 共 5 頁
字號:
<!-- This HTML file has been created by texi2html 1.27
     from library.texinfo on 3 March 1994 -->

<TITLE>The GNU C Library - Sockets</TITLE>
<P>Go to the <A HREF="library_14.html" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_14.html">previous</A>, <A HREF="library_16.html" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_16.html">next</A> section.<P>
<H1><A NAME="SEC216" HREF="library_toc.html#SEC216" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC216">Sockets</A></H1>
<P>
This chapter describes the GNU facilities for interprocess
communication using sockets.
<A NAME="IDX889"></A>
<A NAME="IDX890"></A>
<P>
A <DFN>socket</DFN> is a generalized interprocess communication channel.
Like a pipe, a socket is represented as a file descriptor.  But,
unlike pipes, sockets support communication between unrelated
processes, and even between processes running on different machines
that communicate over a network.  Sockets are the primary means of
communicating with other machines; <CODE>telnet</CODE>, <CODE>rlogin</CODE>,
<CODE>ftp</CODE>, <CODE>talk</CODE>, and the other familiar network programs use
sockets.
<P>
Not all operating systems support sockets.  In the GNU library, the
header file <TT>`sys/socket.h'</TT> exists regardless of the operating
system, and the socket functions always exist, but if the system does
not really support sockets, these functions always fail.
<P>
<STRONG>Incomplete:</STRONG> We do not currently document the facilities for
broadcast messages or for configuring Internet interfaces.
<P>
<H2><A NAME="SEC217" HREF="library_toc.html#SEC217" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC217">Socket Concepts</A></H2>
<A NAME="IDX891"></A>
<A NAME="IDX892"></A>
<P>
When you create a socket, you must specify the style of communication
you want to use and the type of protocol that should implement it.
The <DFN>communication style</DFN> of a socket defines the user-level
semantics of sending and receiving data on the socket.  Choosing a
communication style specifies the answers to questions such as these:
<P>
<UL>
<A NAME="IDX893"></A>
<A NAME="IDX894"></A>
<A NAME="IDX895"></A>
<LI>
<STRONG>What are the units of data transmission?</STRONG>  Some communication
styles regard the data as a sequence of bytes, with no larger
structure; others group the bytes into records (which are known in
this context as <DFN>packets</DFN>).
<P>
<A NAME="IDX896"></A>
<A NAME="IDX897"></A>
<LI>
<STRONG>Can data be lost during normal operation?</STRONG>  Some communication
styles guarantee that all the data sent arrives in the order it was
sent (barring system or network crashes); others styles occasionally
lose data as a normal part of operation, and may sometimes deliver
packets more than once or in the wrong order.
<P>
Designing a program to use unreliable communication styles usually
involves taking precautions to detect lost or misordered packets and
to retransmit data as needed.
<P>
<LI>
<STRONG>Is communication entirely with one partner?</STRONG>  Some
communication styles are like a telephone call--you make a
<DFN>connection</DFN> with one remote socket, and then exchange data
freely.  Other styles are like mailing letters--you specify a
destination address for each message you send.
</UL>
<A NAME="IDX898"></A>
<A NAME="IDX899"></A>
<A NAME="IDX900"></A>
<A NAME="IDX901"></A>
<P>
You must also choose a <DFN>namespace</DFN> for naming the socket.  A socket
name ("address") is meaningful only in the context of a particular
namespace.  In fact, even the data type to use for a socket name may
depend on the namespace.  Namespaces are also called "domains", but we
avoid that word as it can be confused with other usage of the same
term.  Each namespace has a symbolic name that starts with <SAMP>`PF_'</SAMP>.
A corresponding symbolic name starting with <SAMP>`AF_'</SAMP> designates the
address format for that namespace.
<A NAME="IDX902"></A>
<A NAME="IDX903"></A>
<A NAME="IDX904"></A>
<A NAME="IDX905"></A>
<P>
Finally you must next choose the <DFN>protocol</DFN> to carry out the
communication.  The protocol determines what low-level mechanism is used
to transmit and receive data.  Each protocol is valid for a particular
namespace and communication style; a namespace is sometimes called a
<DFN>protocol family</DFN> because of this, which is why the namespace names
start with <SAMP>`PF_'</SAMP>.
<P>
The rules of a protocol apply to the data passing between two programs,
perhaps on different computers; most of these rules are handled by the
operating system, and you need not know about them.  What you do need to
know about protocols is this:
<P>
<UL>
<LI>
In order to have communication between two sockets, they must specify
the <EM>same</EM> protocol.
<P>
<LI>
Each protocol is meaningful with particular style/namespace
combinations and cannot be used with inappropriate combinations.  For
example, the TCP protocol fits only the byte stream style of
communication and the Internet namespace.
<P>
<LI>
For each combination of style and namespace, there is a <DFN>default
protocol</DFN> which you can request by specifying 0 as the protocol
number.  And that's what you should normally do--use the default.
</UL>
<P>
<H2><A NAME="SEC218" HREF="library_toc.html#SEC218" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC218">Communication Styles</A></H2>
<P>
The GNU library includes support for several different kinds of sockets,
each with different characteristics.  This section describes the
supported socket types.  The symbolic constants listed here are
defined in <TT>`sys/socket.h'</TT>.
<A NAME="IDX906"></A>
<P>
<A NAME="IDX907"></A>
<U>Macro:</U> int <B>SOCK_STREAM</B><P>
The <CODE>SOCK_STREAM</CODE> style is like a pipe (see section <A HREF="library_14.html#SEC211" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_14.html#SEC211">Pipes and FIFOs</A>);
it operates over a connection with a particular remote socket, and
transmits data reliably as a stream of bytes.
<P>
Use of this style is covered in detail in section <A HREF="library_15.html#SEC244" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_15.html#SEC244">Using Sockets with Connections</A>.
<P>
<A NAME="IDX908"></A>
<U>Macro:</U> int <B>SOCK_DGRAM</B><P>
The <CODE>SOCK_DGRAM</CODE> style is used for sending
individually-addressed packets, unreliably.  
It is the diametrical opposite of <CODE>SOCK_STREAM</CODE>.
<P>
Each time you write data to a socket of this kind, that data becomes
one packet.  Since <CODE>SOCK_DGRAM</CODE> sockets do not have connections,
you must specify the recipient address with each packet.
<P>
The only guarantee that the system makes about your requests to
transmit data is that it will try its best to deliver each packet you
send.  It may succeed with the sixth packet after failing with the
fourth and fifth packets; the seventh packet may arrive before the
sixth, and may arrive a second time after the sixth.
<P>
The typical use for <CODE>SOCK_DGRAM</CODE> is in situations where it is
acceptible to simply resend a packet if no response is seen in a
reasonable amount of time.
<P>
See section <A HREF="library_15.html#SEC256" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_15.html#SEC256">Datagram Socket Operations</A>, for detailed information about how to use datagram
sockets.
<P>
<A NAME="IDX909"></A>
<U>Macro:</U> int <B>SOCK_RAW</B><P>
This style provides access to low-level network protocols and
interfaces.  Ordinary user programs usually have no need to use this
style.
<P>
<H2><A NAME="SEC219" HREF="library_toc.html#SEC219" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC219">Socket Addresses</A></H2>
<A NAME="IDX910"></A>
<A NAME="IDX911"></A>
<A NAME="IDX912"></A>
<A NAME="IDX913"></A>
<P>
The name of a socket is normally called an <DFN>address</DFN>.  The
functions and symbols for dealing with socket addresses were named
inconsistently, sometimes using the term "name" and sometimes using
"address".  You can regard these terms as synonymous where sockets
are concerned.
<P>
A socket newly created with the <CODE>socket</CODE> function has no
address.  Other processes can find it for communication only if you
give it an address.  We call this <DFN>binding</DFN> the address to the
socket, and the way to do it is with the <CODE>bind</CODE> function.
<P>
You need be concerned with the address of a socket if other processes
are to find it and start communicating with it.  You can specify an
address for other sockets, but this is usually pointless; the first time
you send data from a socket, or use it to initiate a connection, the
system assigns an address automatically if you have not specified one.
<P>
Occasionally a client needs to specify an address because the server
discriminates based on addresses; for example, the rsh and rlogin
protocols look at the client's socket address and don't bypass password
checking unless it is less than <CODE>IPPORT_RESERVED</CODE> (see section <A HREF="library_15.html#SEC234" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_15.html#SEC234">Internet Ports</A>).
<P>
The details of socket addresses vary depending on what namespace you are
using.  See section <A HREF="library_15.html#SEC223" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_15.html#SEC223">The File Namespace</A>, or section <A HREF="library_15.html#SEC227" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_15.html#SEC227">The Internet Namespace</A>, for specific
information.
<P>
Regardless of the namespace, you use the same functions <CODE>bind</CODE> and
<CODE>getsockname</CODE> to set and examine a socket's address.  These
functions use a phony data type, <CODE>struct sockaddr *</CODE>, to accept the
address.  In practice, the address lives in a structure of some other
data type appropriate to the address format you are using, but you cast
its address to <CODE>struct sockaddr *</CODE> when you pass it to
<CODE>bind</CODE>.
<P>
<H3><A NAME="SEC220" HREF="library_toc.html#SEC220" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC220">Address Formats</A></H3>
<P>
The functions <CODE>bind</CODE> and <CODE>getsockname</CODE> use the generic data
type <CODE>struct sockaddr *</CODE> to represent a pointer to a socket
address.  You can't use this data type effectively to interpret an
address or construct one; for that, you must use the proper data type
for the socket's namespace.
<P>
Thus, the usual practice is to construct an address in the proper
namespace-specific type, then cast a pointer to <CODE>struct sockaddr *</CODE>
when you call <CODE>bind</CODE> or <CODE>getsockname</CODE>.
<P>
The one piece of information that you can get from the <CODE>struct
sockaddr</CODE> data type is the <DFN>address format</DFN> designator which tells
you which data type to use to understand the address fully.
<A NAME="IDX914"></A>
<P>
The symbols in this section are defined in the header file
<TT>`sys/socket.h'</TT>.
<P>
<A NAME="IDX915"></A>
<U>Date Type:</U> <B>struct sockaddr</B><P>
The <CODE>struct sockaddr</CODE> type itself has the following members:
<P>
<DL COMPACT>
<DT><CODE>short int sa_family</CODE>
<DD>This is the code for the address format of this address.  It
identifies the format of the data which follows.
<P>
<DT><CODE>char sa_data[14]</CODE>
<DD>This is the actual socket address data, which is format-dependent.  Its
length is also format-dependent, and may well be more than 14.  The
length 14 of <CODE>sa_data</CODE> is essentially arbitrary.
</DL>
<P>
Each address format has a symbolic name which starts with <SAMP>`AF_'</SAMP>.
Each of them corresponds to a <SAMP>`PF_'</SAMP> symbol which designates the
corresponding namespace.  Here is a list of address format names:
<P>
<DL COMPACT>
<A NAME="IDX916"></A>
<DT><CODE>AF_FILE</CODE>
<DD>This designates the address format that goes with the file namespace.
(<CODE>PF_FILE</CODE> is the name of that namespace.)  See section <A HREF="library_15.html#SEC225" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_15.html#SEC225">Details of File Namespace</A>, for information about this address format.
<P>
<A NAME="IDX917"></A>
<DT><CODE>AF_UNIX</CODE>
<DD>This is a synonym for <CODE>AF_FILE</CODE>, for compatibility.
(<CODE>PF_UNIX</CODE> is likewise a synonym for <CODE>PF_FILE</CODE>.)
<P>
<A NAME="IDX918"></A>
<DT><CODE>AF_INET</CODE>
<DD>This designates the address format that goes with the Internet
namespace.  (<CODE>PF_INET</CODE> is the name of that namespace.)
See section <A HREF="library_15.html#SEC228" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_15.html#SEC228">Internet Socket Address Format</A>.
<P>
<A NAME="IDX919"></A>
<DT><CODE>AF_UNSPEC</CODE>
<DD>This designates no particular address format.  It is used only in rare
cases, such as to clear out the default destination address of a
"connected" datagram socket.  See section <A HREF="library_15.html#SEC257" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_15.html#SEC257">Sending Datagrams</A>.
<P>
The corresponding namespace designator symbol <CODE>PF_UNSPEC</CODE> exists
for completeness, but there is no reason to use it in a program.
</DL>

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久99日本精品| 亚洲综合视频网| 国产精品一级二级三级| 久久久亚洲高清| 99久久精品久久久久久清纯| 亚洲天堂精品在线观看| 欧美日韩一二三| 狠狠色丁香婷综合久久| 国产精品久久久久婷婷二区次| 99精品黄色片免费大全| 午夜精品久久久久久久99水蜜桃 | 日韩一级高清毛片| 国精产品一区一区三区mba桃花 | 日韩视频免费观看高清完整版 | 色婷婷综合久久久久中文一区二区| 亚洲一区二区三区爽爽爽爽爽 | 国产亚洲欧美在线| 91尤物视频在线观看| 亚洲 欧美综合在线网络| 精品国产电影一区二区| www.一区二区| 青青青爽久久午夜综合久久午夜| 久久精品水蜜桃av综合天堂| 欧美在线观看视频一区二区| 久久超级碰视频| 亚洲三级久久久| 久久人人97超碰com| 一本色道久久综合亚洲aⅴ蜜桃| 日韩精品免费专区| 国产无人区一区二区三区| 欧美乱妇15p| 不卡大黄网站免费看| 日本中文在线一区| 1区2区3区精品视频| 日韩美女视频一区二区在线观看| 91在线观看污| 国产一区二区剧情av在线| 夜色激情一区二区| 国产精品三级视频| 日韩精品一区国产麻豆| 欧美三级在线视频| 99久久99久久精品免费观看| 久久精品国产精品亚洲精品| 亚洲精品欧美专区| 国产亚洲精久久久久久| 日韩免费视频一区二区| 欧美日韩一区不卡| 色综合天天综合| 成人高清免费观看| 精品一区二区综合| 日本不卡的三区四区五区| 亚洲免费视频中文字幕| 中文字幕免费观看一区| 精品剧情在线观看| 欧美一区二区三区免费视频| 欧美日韩中文字幕一区二区| 91网站在线播放| 成人美女在线观看| 国产黄色成人av| 国产一区二区福利| 久久不见久久见中文字幕免费| 视频一区二区中文字幕| 亚洲成a人v欧美综合天堂| 亚洲天堂av老司机| **欧美大码日韩| 欧美激情综合网| 国产欧美一区二区精品忘忧草| 欧美不卡在线视频| 日韩精品专区在线影院重磅| 欧美一区在线视频| 日韩亚洲欧美一区| 日韩视频免费观看高清完整版| 欧美巨大另类极品videosbest | 中文字幕欧美激情| 日本一区二区电影| 国产精品久99| ...xxx性欧美| 一二三区精品视频| 午夜精品爽啪视频| 免费日本视频一区| 国产中文字幕精品| 福利电影一区二区三区| 不卡电影免费在线播放一区| 99re热视频这里只精品| 欧美在线观看一二区| 3atv在线一区二区三区| 日韩欧美一二三| 精品国产乱码久久久久久蜜臀| 日韩欧美一级二级三级久久久| 久久婷婷色综合| 国产精品久久久久天堂| 亚洲精品自拍动漫在线| 亚洲综合视频在线| 男女视频一区二区| 国产精品影视在线观看| 成人avav影音| 欧美日韩一区二区三区在线| 精品日韩在线观看| 国产精品伦一区二区三级视频| 亚洲欧洲精品成人久久奇米网| 一区二区不卡在线播放 | 精品国产99国产精品| 国产亚洲精品aa午夜观看| 一区二区理论电影在线观看| 日本不卡视频在线| 成人av电影免费观看| 欧美精品一二三| 国产午夜精品一区二区三区视频| 亚洲精品伦理在线| 久久www免费人成看片高清| www.在线欧美| 日韩一区二区三区视频| 国产精品国产三级国产三级人妇| 亚洲国产精品一区二区www| 国产在线不卡一区| 日本国产一区二区| 久久久久国产精品厨房| 亚洲一二三四在线| 国内精品在线播放| 欧美在线一二三四区| 久久久久国产一区二区三区四区| 一区二区三区小说| 国产成人自拍网| 欧美一区二区在线观看| 日韩理论在线观看| 国精产品一区一区三区mba桃花 | 亚洲第一综合色| 国产成人免费高清| 日韩久久久精品| 亚洲成人一区二区| 91视频com| 国产女人aaa级久久久级| 婷婷丁香久久五月婷婷| 99久久综合狠狠综合久久| 日韩欧美在线影院| 亚洲成人激情综合网| 99久久99久久精品免费看蜜桃| 久久青草欧美一区二区三区| 亚洲成av人片在线观看| 91在线一区二区| 国产亚洲1区2区3区| 免费观看日韩电影| 欧美日韩免费高清一区色橹橹| 欧美激情在线观看视频免费| 狠狠色丁香久久婷婷综| 欧美人牲a欧美精品| 亚洲精品第1页| 91麻豆免费看片| 中文欧美字幕免费| 国产盗摄女厕一区二区三区 | 欧美美女激情18p| 又紧又大又爽精品一区二区| caoporen国产精品视频| 欧美激情一区不卡| 国产剧情一区二区| 久久综合久久综合久久综合| 美女视频黄频大全不卡视频在线播放| 欧美性猛交xxxx乱大交退制版| 亚洲日本护士毛茸茸| 99久久精品久久久久久清纯| 国产精品国产三级国产a | 狠狠色丁香婷婷综合久久片| 欧美一区二区三区四区高清| 免费精品视频在线| 日韩欧美国产一区二区在线播放 | 日本一区二区在线不卡| 福利电影一区二区| 国产精品美女久久久久久久久 | 亚洲人吸女人奶水| www.成人网.com| 亚洲人成伊人成综合网小说| 91小视频在线免费看| 亚洲激情中文1区| 欧美色综合久久| 石原莉奈在线亚洲二区| 日韩一区二区三区免费看 | 日韩一区二区三区视频在线| 蜜桃视频免费观看一区| 26uuu亚洲综合色| 国产成人超碰人人澡人人澡| 国产精品国产自产拍高清av王其 | 精品国产免费一区二区三区四区 | 久久国内精品视频| 久久久久久99久久久精品网站| 高清国产一区二区三区| 亚洲欧洲精品一区二区三区不卡| 在线一区二区视频| 免费成人性网站| 久久免费看少妇高潮| 91污片在线观看| 日本成人在线电影网| 国产农村妇女精品| 欧美亚洲另类激情小说| 久久99国产精品免费网站| 中文字幕一区二区三| 日韩一区二区高清| 不卡的电视剧免费网站有什么| 亚洲超丰满肉感bbw| 久久久精品影视| 欧洲视频一区二区|