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

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

?? rhl54.htm

?? linux的初學(xué)電子書
?? HTM
?? 第 1 頁 / 共 2 頁
字號:
<HTML>

<HEAD>

<TITLE>Red Hat Linux Unleashed rhl54.htm </TITLE>

<LINK REL="ToC" HREF="index-1.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/index.htm">

<LINK REL="Index" HREF="htindex.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/htindex.htm">

<LINK REL="Next" HREF="rhl55.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/rhl55.htm">

<LINK REL="Previous" HREF="rhl53.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/rhl53.htm"></HEAD>

<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080">

<A NAME="I0"></A>

<H2>Red Hat Linux Unleashed rhl54.htm</H2>

<P ALIGN=LEFT>

<A HREF="rhl53.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/rhl53.htm" TARGET="_self"><IMG SRC="purprev.gif" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/purprev.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Previous Page"></A>

<A HREF="index-1.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/index.htm" TARGET="_self"><IMG SRC="purtoc.gif" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/purtoc.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="TOC"></A>

<A HREF="rhl55.htm" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/rhl55.htm" TARGET="_self"><IMG SRC="purnext.gif" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/purnext.gif" WIDTH = 32 HEIGHT = 32 BORDER = 0 ALT="Next Page"></A>


<HR ALIGN=CENTER>

<P>

<UL>

<UL>

<UL>

<LI>

<A HREF="#E68E415" >Ports and Sockets</A>

<LI>

<A HREF="#E68E416" >Socket Programming</A>

<UL>

<LI>

<A HREF="#E69E535" >socket()</A>

<LI>

<A HREF="#E69E536" >The bind() System Call</A>

<LI>

<A HREF="#E69E537" >The listen() System Call</A>

<LI>

<A HREF="#E69E538" >The accept() System Call</A>

<LI>

<A HREF="#E69E539" >The connect() System Call</A>

<LI>

<A HREF="#E69E540" >Connectionless Socket Programming</A></UL>

<LI>

<A HREF="#E68E417" >Record and File Locking</A>

<LI>

<A HREF="#E68E418" >Interprocess Communications</A>

<LI>

<A HREF="#E68E419" >Summary</A></UL></UL></UL>

<HR ALIGN=CENTER>

<A NAME="E66E54"></A>

<H1 ALIGN=CENTER>

<CENTER>

<FONT SIZE=6 COLOR="#FF0000"><B>54</B></FONT></CENTER></H1>

<BR>

<A NAME="E67E54"></A>

<H2 ALIGN=CENTER>

<CENTER>

<FONT SIZE=6 COLOR="#FF0000"><B>Network Programming</B></FONT></CENTER></H2>

<BR>

<P>This chapter will look at the basic concepts you need for network programming:

<BR>

<UL>

<LI>Ports and sockets

<BR>

<BR>

<LI>Record and file locking

<BR>

<BR>

<LI>Interprocess communications

<BR>

<BR>

</UL>

<P>It is impossible to tell you how to program applications for a network in just a few pages. Indeed, the best reference to network programming available takes almost 800 pages in the first volume alone! If you really want to do network programming, you 
need a lot of experience with compilers, TCP/IP, network operating systems, and a great deal of patience.

<BR>

<P>For information on details of TCP/IP, check the book Teach Yourself TCP/IP in 14 Days by Tim Parker (Sams).

<BR>

<BR>

<A NAME="E68E415"></A>

<H3 ALIGN=CENTER>

<CENTER>

<FONT SIZE=5 COLOR="#FF0000"><B>Ports and Sockets</B></FONT></CENTER></H3>

<BR>

<P>Network programming relies on the use of sockets to accept and transmit information. Although there is a lot of mystique about sockets, the concept is actually very simple to understand.

<BR>

<P>Most applications that use the two primary network protocols, Transmission Control Protocol (TCP) or User Datagram Protocol (UDP) have a port number that identifies the application. A port number is used for each different application the machine is 
handling, so it can keep track of them by numbers instead of names. The port number makes it easier for the operating system to know how many applications are using the system and which services are available.

<BR>

<P>In theory, port numbers can be assigned on individual machines by the system administrator, but some conventions have been adopted to allow better communications. This convention enables the port number to identify the type of service that one system is 
requesting from another. For this reason, most systems maintain a file of port numbers and their corresponding services.

<BR>

<P>Port numbers are assigned starting from the number 1. Normally, port numbers above 255 are reserved for the private use of the local machine, but numbers between 1 and 255 are used for processes requested by remote applications or for networking 
services.

<BR>

<P>Each network communications circuit that goes into and out of the host computer's TCP application layer is uniquely identified by a combination of two numbers, together called the socket. The socket is composed of the IP address of the machine and the 
port number used by the TCP software.

<BR>

<P>Because there are at least two machines involved in network communications, there will be a socket on both the sending and receiving machine. The IP address of each machine is unique, and the port numbers are unique to each machine, so socket numbers 
will also be unique across the network. This enables an application to talk to another application across the network based entirely on the socket number.

<BR>

<P>The sending and receiving machines maintain a port table that lists all active port numbers. The two machines involved have reversed entries for each session between the two, a process called binding. In other words, if one machine has the source port 
number 23 and the destination port number set at 25, then the other machine will have its source port number set at 25 and the destination port number set at 23.

<BR>

<BR>

<A NAME="E68E416"></A>

<H3 ALIGN=CENTER>

<CENTER>

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

<BR>

<P>Linux supports BSD style socket programming. Both connection-oriented and connectionless types of sockets are supported. In connection-oriented communication, the server and client establish a connection before any data is exchanged. In connectionless 
communication, data is exchanged as part of a message. In either case, the server always starts up first, binds itself to a socket, and listens to messages. How the server attempts to listen depends on the type of connection for which you have programmed 
it.

<BR>

<P>You need to know about only a few system calls:

<BR>

<UL>

<LI>socket()

<BR>

<BR>

<LI>bind()

<BR>

<BR>

<LI>accept()

<BR>

<BR>

<LI>listen()

<BR>

<BR>

<LI>connect()

<BR>

<BR>

<LI>sendto()

<BR>

<BR>

<LI>recvfrom()

<BR>

<BR>

</UL>

<P>We will cover these in the following examples.

<BR>

<BR>

<A NAME="E69E535"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>socket()</B></FONT></CENTER></H4>

<BR>

<P>The socket() system call creates a socket for the client or the server. The socket function is defined as follows:

<BR>

<PRE>

<FONT COLOR="#000080">#include&lt;sys/types.h&gt;

#include&lt;sys/socket.h&gt;

int socket(int family, int type, int protocol)</FONT></PRE>

<P>For Linux, you will have family = AF_UNIX. The type is either SOCK_STREAM for reliable, though slower communications or SOCK_DGRAM for faster, but less reliable communications. The protocol should be IPPROTO_TCP for SOCK_STREAM and IPPROTO_UDP for 
SOCK_DGRAM.

<BR>

<P>The return value from this function is -1 if there was an error; otherwise, it's a socket descriptor. You will use this socket descriptor to refer to this socket in all subsequent calls in your program.

<BR>

<P>Sockets are created without a name. Clients use the name of the socket in order to read or write to it. This is where the bind function comes in.

<BR>

<BR>

<A NAME="E69E536"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>The </B><B>bind()</B><B> System Call</B></FONT></CENTER></H4>

<BR>

<P>The bind() system call assigns a name to an unnamed socket.

<BR>

<PRE>

<FONT COLOR="#000080">#include&lt;sys/types.h&gt;

#include&lt;sys/socket.h&gt;

int bind(int sockfd, struct sockaddr *saddr, int addrlen)</FONT></PRE>

<P>The first item is a socket descriptor. The second is a structure with the name to use, and the third item is the size of the structure.

<BR>

<P>Now that you have bound an address for your server or client, you can connect() to it or listen on it. If your program is a server, then it sets itself up to listen and accept connections. Let's look at the function available for such an endeavor.

<BR>

<BR>

<A NAME="E69E537"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>The </B><B>listen()</B><B> System Call</B></FONT></CENTER></H4>

<BR>

<P>The listen() system call is used by the server. It is defined as follows:

<BR>

<PRE>

<FONT COLOR="#000080">#include&lt;sys/types.h&gt;

#include&lt;sys/socket.h&gt;

int listen(int sockfd, int backlog);</FONT></PRE>

<P>The sockfd is the descriptor of the socket. The backlog is the number of waiting connections at one time before rejecting any. Use the standard value of 5 for backlog. A returned value of less than 1 indicates an error.

<BR>

<P>If this call is successful, you can accept connections.

<BR>

<BR>

<A NAME="E69E538"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>The </B><B>accept()</B><B> System Call</B></FONT></CENTER></H4>

<BR>

<P>The accept() system call is used by a server to accept any incoming messages from clients' connect() calls. Be aware that this function will not return if no connections are received.

<BR>

<PRE>

<FONT COLOR="#000080">#include&lt;sys/types.h&gt;

#include&lt;sys/socket.h&gt;

int accept(int sockfd, struct sockaddr *peeraddr, int addrlen)</FONT></PRE>

<P>The parameters are the same as that for the bind call, with the exception that the peeraddr points to information about the client that is making a connection request. Based on the incoming message, the fields in the structure pointed at by peeraddr are 
filled out.

<BR>

<P>So how does a client connect to a server. Let's look at the connect() call.

<BR>

<BR>

<A NAME="E69E539"></A>

<H4 ALIGN=CENTER>

<CENTER>

<FONT SIZE=4 COLOR="#FF0000"><B>The </B><B>connect()</B><B> System Call</B></FONT></CENTER></H4>

<BR>

<P>The connect() system call is used by clients to connect to a server in a connection-oriented system. This connect() call should be made after the bind() call.

<BR>

<PRE>

<FONT COLOR="#000080">#include&lt;sys/types.h&gt;

#include&lt;sys/socket.h&gt;

int connect(int sockfd, struct sockaddr *servsaddr, int addrlen)</FONT></PRE>

<P>The parameters are the same as that for the bind call, with the exception that the servsaddr points to information about the server that the client is connecting to. The accept call creates a new socket for the server to work with the request. This way 
the server can fork() off a new process and wait for more connections. On the server side of things, you would have code that looks like that shown in Listing 54.1.

<BR>

<P>

<FONT COLOR="#000080"><B>Listing 54.1. Server side for socket-oriented protocol.</B></FONT>

<BR>

<PRE>

<FONT COLOR="#000080">#include &lt;sys/types.h&gt;

#include &lt;sys/socket.h&gt;

#include &lt;linux/in.h&gt;

#include &lt;linux/net.h&gt;

#define MY_PORT 6545

main(int argc, char *argv[])

{

int sockfd, newfd;

int cpid; /* child id */

struct sockaddr_in servaddr;

struct sockaddr_in clientInfo;

if ((sockfd = socket(AF_INET, SOCK_STREAM, 0) &lt; 0)

{

myabort(&quot;Unable to create socket&quot;);

}

bzero((char *)&amp;servaddr, sizeof(servaddr));

servaddr.sin_family = AF_INET;

servaddr.sin_addr.s_addr = htonl(INADDR_ANY);

servaddr.sin_family = htons(MY_PORT);

/*

* The htonl(for a long integer) and htons(for short integer) convert

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
色老汉一区二区三区| 国产亚洲1区2区3区| 亚洲一区自拍偷拍| 色吊一区二区三区| 亚洲一区二区三区精品在线| 欧美性受xxxx黑人xyx性爽| 亚洲成人高清在线| 91麻豆精品国产91久久久久 | 天堂在线亚洲视频| 日韩视频永久免费| 成人午夜av影视| 亚洲精品免费一二三区| 在线不卡a资源高清| 奇米色一区二区三区四区| 久久久亚洲综合| 91在线免费看| 日本午夜精品一区二区三区电影| 精品国产乱码久久久久久老虎| 成人免费看视频| 一区二区国产视频| 欧美精品一区二区三| 99视频在线精品| 午夜精品福利一区二区三区蜜桃| 日韩三级精品电影久久久| 国产精品亚洲第一| 亚洲成av人片在线观看无码| 精品国产在天天线2019| 91丝袜美腿高跟国产极品老师| 偷拍亚洲欧洲综合| 欧美激情一区二区三区不卡| 欧美性xxxxx极品少妇| 国产精品自拍毛片| 亚洲成av人片在线| 国产精品欧美综合在线| 91精品国产福利在线观看| 丰满少妇在线播放bd日韩电影| 亚洲自拍欧美精品| 亚洲国产高清aⅴ视频| 884aa四虎影成人精品一区| 成人精品视频.| 麻豆国产精品一区二区三区| 亚洲男人天堂一区| 久久亚洲综合av| 3d动漫精品啪啪1区2区免费| 91在线高清观看| 国产乱码精品一区二区三区忘忧草| 亚洲一二三四在线| 一色桃子久久精品亚洲| 亚洲精品一区二区三区四区高清 | 视频在线观看一区二区三区| 国产精品私人影院| 精品国产乱码久久久久久蜜臀| 欧洲色大大久久| 成人性生交大片| 国内精品免费**视频| 欧美a一区二区| 亚洲一区电影777| 亚洲精品日日夜夜| 国产精品妹子av| 国产女主播一区| 2023国产精品自拍| 精品国产乱码久久久久久老虎 | 国产日韩成人精品| 欧美va天堂va视频va在线| 91精品国产乱码| 91精品国产乱| 91精品国产一区二区三区香蕉 | 日韩国产精品久久久久久亚洲| 亚洲精品国产成人久久av盗摄| 国产亚洲欧美一级| 久久免费偷拍视频| 久久综合网色—综合色88| 日韩免费高清av| 精品少妇一区二区三区视频免付费| 91.麻豆视频| 欧美日韩精品一区二区天天拍小说 | 色综合激情久久| 97精品电影院| 色爱区综合激月婷婷| 亚洲国产美女搞黄色| 久久精品在这里| 日韩精品一区二区三区四区视频| 日韩午夜中文字幕| 亚洲精品一区二区三区蜜桃下载 | 午夜一区二区三区在线观看| 亚洲成人自拍网| 欧美aaaaa成人免费观看视频| 日韩国产欧美在线观看| 久久精品国产一区二区三 | 国产精品麻豆视频| 一区免费观看视频| 亚洲成a天堂v人片| 青青草成人在线观看| 精品一区二区精品| 国产成人精品影院| 日本高清不卡一区| 91精品国产乱码| 欧美国产一区在线| 一区二区三区在线播放| 婷婷开心久久网| 黑人精品欧美一区二区蜜桃| www.一区二区| 欧美二区在线观看| 欧美激情资源网| 一区二区视频免费在线观看| 亚洲国产精品一区二区久久 | 欧美日韩国产区一| www国产精品av| 亚洲欧洲性图库| 日韩国产欧美视频| 成人自拍视频在线| 欧美喷潮久久久xxxxx| 26uuu精品一区二区在线观看| 亚洲色图在线播放| 日韩电影在线一区| 成人精品高清在线| 欧美一区二区三区在线| 中文字幕乱码亚洲精品一区| 午夜精品影院在线观看| 国产盗摄精品一区二区三区在线 | 99久久精品免费| 日韩亚洲欧美成人一区| 亚洲日本免费电影| 精品亚洲porn| 欧美日韩一区三区| 国产精品免费视频观看| 日韩影院免费视频| 91美女在线视频| 国产清纯美女被跳蛋高潮一区二区久久w | 国产成人免费视频一区| 欧美日本在线观看| 亚洲色图视频网| 国产一区在线观看视频| 欧美久久婷婷综合色| 成人欧美一区二区三区视频网页| 蜜臀va亚洲va欧美va天堂| 色久优优欧美色久优优| 久久久99免费| 日本美女视频一区二区| 日本道精品一区二区三区| 国产三级欧美三级日产三级99| 视频一区视频二区在线观看| 91九色02白丝porn| 国产精品丝袜在线| 国产精品一区二区视频| 日韩欧美成人一区二区| 视频在线观看一区| 欧美人体做爰大胆视频| 亚洲人成人一区二区在线观看| 国产成人精品午夜视频免费| 欧美成人官网二区| 五月天激情小说综合| 91成人免费在线| 亚洲欧洲精品天堂一级| 成人丝袜高跟foot| 国产午夜精品一区二区三区嫩草 | 26uuu亚洲综合色欧美| 三级在线观看一区二区| 欧美综合在线视频| 亚洲最大成人综合| 在线精品视频一区二区三四| 亚洲日本一区二区| 色综合色综合色综合| 亚洲三级在线看| 一本到不卡精品视频在线观看| 18成人在线观看| 日本乱人伦一区| 亚洲欧美激情在线| 91国产福利在线| 亚洲成人黄色小说| 日韩西西人体444www| 精品一区二区在线视频| 精品成人一区二区| 国产精品亚洲а∨天堂免在线| 久久精品欧美一区二区三区麻豆| 国产麻豆精品theporn| 国产亚洲欧美在线| 99国产精品一区| 亚洲一卡二卡三卡四卡| 欧美疯狂做受xxxx富婆| 久久精品国产99国产| 国产亚洲综合av| 91亚洲精品久久久蜜桃网站| 一二三四社区欧美黄| 欧美丰满少妇xxxxx高潮对白 | 中文字幕第一区综合| 97精品国产露脸对白| 爽爽淫人综合网网站| 久久综合九色综合欧美亚洲| 成人午夜电影网站| 亚洲综合av网| 亚洲精品在线观看网站| 成人免费看片app下载| 亚洲综合无码一区二区| 欧美一级夜夜爽| 国产成人亚洲综合a∨猫咪| 一区二区三区中文字幕电影| 欧美精品tushy高清| 国产一区二区三区免费观看| 亚洲丝袜美腿综合|