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

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

?? ch20.htm

?? vc學習相關書籍,希望對大家有幫助,如果不好請批評指正
?? HTM
?? 第 1 頁 / 共 4 頁
字號:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"><HTML><HEAD>	<META HTTP-EQUIV="Content-Type" CONTENT="text/html;CHARSET=iso-8859-1"><SCRIPT LANGUAGE="JavaScript"><!--function popUp(pPage) { var fullURL = document.location; var textURL = fullURL.toString(); var URLlen = textURL.length; var lenMinusPage = textURL.lastIndexOf("/"); lenMinusPage += 1; var fullPath = textURL.substring(0,lenMinusPage); popUpWin = window.open('','popWin','resizable=yes,scrollbars=no,width=525,height=394'); figDoc= popUpWin.document; zhtm= '<HTML><HEAD><TITLE>' + pPage + '</TITLE>'; zhtm += '</head>'; zhtm += '<BODY bgcolor="#FFFFFF">'; zhtm += '<IMG SRC="' + fullPath + pPage + '">'; zhtm += '<P><B>' + pPage + '</B>'; zhtm += '</BODY></HTML>'; window.popUpWin.document.write(zhtm); window.popUpWin.document.close(); // Johnny Jackson 4/28/98 }//-->                                                                </SCRIPT><link rel="stylesheet" href="/includes/stylesheets/ebooks.css">	<META NAME="GENERATOR" Content="Symantec Visual Page Mac 1.1.1">	<TITLE>Teach Yourself Visual C++ 6 in 21 Days -- Ch 20 -- Internet Applications and Network Communications</TITLE></HEAD><BODY TEXT="#000000" BGCOLOR="#FFFFFF"><H1 ALIGN="CENTER"><IMG SRC="../button/sams.gif" WIDTH="171" HEIGHT="66" ALIGN="BOTTOM"BORDER="0"><BR>Teach Yourself Visual C++ 6 in 21 Days</H1><CENTER><P><A HREF="../ch19/ch19.htm"><IMG SRC="../button/previous.gif" WIDTH="128" HEIGHT="28"ALIGN="BOTTOM" ALT="Previous chapter" BORDER="0"></A><A HREF="../ch21/ch21.htm"><IMGSRC="../button/next.gif" WIDTH="128" HEIGHT="28" ALIGN="BOTTOM" ALT="Next chapter"BORDER="0"></A><A HREF="../index.htm"><IMG SRC="../button/contents.gif" WIDTH="128"HEIGHT="28" ALIGN="BOTTOM" ALT="Contents" BORDER="0"></A> <HR></CENTER><H1 ALIGN="CENTER">- 20 -<BR>Internet Applications and Network Communications</H1><H1></H1><UL>	<LI><A HREF="#Heading1">How Do Network Communications Work?</A>	<UL>		<LI><A HREF="#Heading2">Sockets, Ports, and Addresses</A>		<LI><A HREF="#Heading3">Creating a Socket</A>		<LI><A HREF="#Heading4">Making a Connection</A>		<LI><A HREF="#Heading5">Sending and Receiving Messages</A>		<LI><A HREF="#Heading6">Closing the Connection</A>		<LI><A HREF="#Heading7">Socket Events</A>		<LI><A HREF="#Heading8">Detecting Errors</A>	</UL>	<LI><A HREF="#Heading9">Building a Networked Application</A>	<UL>		<LI><A HREF="#Heading10">Creating the Application Shell</A>		<LI><A HREF="#Heading11">Inheriting from the CAsyncSocket Class</A>		<LI><A HREF="#Heading12">Connecting the Application</A>		<LI><A HREF="#Heading13">Sending and Receiving</A>		<LI><A HREF="#Heading14">Ending the Connection</A>	</UL>	<LI><A HREF="#Heading15">Summary</A>	<LI><A HREF="#Heading16">Q&amp;A</A>	<LI><A HREF="#Heading17">Workshop</A>	<UL>		<LI><A HREF="#Heading18">Quiz</A>		<LI><A HREF="#Heading19">Exercise</A>	</UL></UL><P><HR SIZE="4"><BR>Thanks in part to the explosion in popularity of the Internet, more applicationshave the ability to communicate with other applications over networks, includingthe Internet. With Microsoft building networking capabilities into its operatingsystems, starting with Windows NT and Windows 95, these capabilities are becomingcommonplace in all sorts of applications.</P><P>Some applications perform simple networking tasks such as checking with a Website to see whether there are any updates to the program and giving the user theoption of updating her copy of the program. Some word processing applications willformat documents as Web pages, giving the user the option of loading the pages ontothe Web server. You've got computer games that allow the user to play against anotherperson halfway around the world instead of just competing against the game itself.</P><P>Applications can have any number of networking functions, and they all are builtaround the Winsock interface. If you know and understand how to program using theWinsock interface and the MFC Winsock classes, this entire realm of application programmingis open to you, expanding your programming options considerably. Today, you willlearn</P><P><UL>	<LI>How applications use the Winsock interface to perform network communications	between two or more computers.	<P>	<LI>The difference between a client and a server application and the role each plays	in establishing a communications link.	<P>	<LI>How the MFC Winsock classes simplify the process of writing Internet applications.	<P>	<LI>How you can create your own Winsock class, descended from the MFC Winsock classes,	to easily build an event-driven, networking application.</UL><H2><A NAME="Heading1"></A>How Do Network Communications Work?</H2><P>Most applications that communicate over a network, whether it's the Internet ora small office network, use the same principles and functionality to perform theircommunication. One application sits on a computer, waiting for another applicationto open a communication connection. This application is &quot;listening&quot; forthis connection request, much like you listen for the phone to ring if you are expectingsomeone to call.</P><P>Meanwhile, another application, most likely on another computer (but not necessarily),tries to connect to the first application. This attempt to open a connection is similarto calling someone on the telephone. You dial the number and hope that the otherperson is listening for the phone on the other end. As the person making the call,you have to know the phone number of the person you are calling. If you don't knowthe phone number, you can look it up using the person's name. Likewise, the applicationtrying to connect to the first application has to know the network location, or address,of the first application.</P><P>Once the connection is made between the two applications, messages can pass backand forth between the two applications, much like you can talk to the person on theother end of the phone. This connection is a two-way communications channel, withboth sides sending information, as shown in Figure 20.l.</P><P><A HREF="javascript:popUp('20fig01.gif')"><B>FIGURE 20.1.</B></A><B> </B><I>Thebasic socket connection process.</I></P><P>Finally, once one or both sides have finished their sides of the conversation,the connection is closed, much like you hang up the phone after you have finishedtalking to the person you called. Once the connection is closed from either side,the other side can detect it and close its side, just like you can tell if the personon the other end of the phone has hung up on you or if you've been disconnected bysome other means. This is a basic explanation of how network communications workbetween two or more applications.</P><BLOCKQUOTE>	<P><HR><STRONG>NOTE:</STRONG> This is a basic description of how network communications work with	the TCP/IP network protocol, which is the primary network protocol over the Internet.	Many other network protocols use a subtle variation on this description. Other protocols,	such as the UDP protocol, are more like radio broadcasts, where there is no connection	between the two applications; one sends messages, and the other is responsible for	making sure that it receives all of the messages. These protocols are more involved	than we have the luxury to discuss today. If you want to learn more about network	protocols and how they work, many books cover this one topic and look at the various	Internet applications and how they communicate over the connections they establish.<HR></BLOCKQUOTE><H3><A NAME="Heading2"></A>Sockets, Ports, and Addresses</H3><P>The basic object used by applications to perform most network communications iscalled a socket. Sockets were first developed on UNIX at the University of Californiaat Berkley. Sockets were designed so that most network communications between applicationscould be performed in the same way that these same applications would read and writefiles. Sockets have progressed quite a bit since then, but the basics of how theywork are still the same.</P><P>During the days of Windows 3.<I>x</I>, before networking was built into the Windowsoperating system, you could buy the network protocols required for network communicationsfrom numerous different companies. Each of these companies had a slightly differentway that an application performed network communications. As a result, any applicationsthat performed network communications had a list of the different networking softwarethat the application would work with. Many application developers were not happywith this situation. As a result, all the networking companies, including Microsoft,got together and developed the Winsock (Windows Sockets) API. This provided all applicationdevelopers with a consistent API to perform all network communications, regardlessof the networking software used.</P><P>When you want to read or write a file, you must use a file object to point tothe file. Although this was hidden from you in most of the Visual C++ applicationsso far, with the ActiveX control you created yesterday, you had to work through thesteps of creating the file object for reading and writing. A socket is similar; itis an object used to read and write messages that travel between applications.</P><P>Making a socket connection to another application does require a different setof information than opening a file. To open a file, you need to know the file's nameand location. To open a socket connection, you need to know the computer on whichthe other application is running and the port on which it's listening. A port islike a phone extension, and the computer address is like the phone number. If youcall someone at a large office building, you may dial the main office number, butthen you need to specify the extension number. Likewise, ports are used to routenetwork communications (see Figure 20.2). As with the phone number, there are meansof looking up the port number, if you don't already know what it is, but this requiresyour computer to be configured with the information about which port the connectingapplication is listening on. If you specify the wrong computer address or port number,you may get a connection to a different application; with making the phone call,someone other than the person you called may answer the phone call. You also maynot get an answer at all if there is no application listening at the other end.</P><BLOCKQUOTE>	<P><HR><STRONG>NOTE:</STRONG> Only one application may be listening on any specific port on a single	computer. Although numerous applications may listen for connection requests on a	single computer at the same time, each of these applications must listen on a different	port.<HR></BLOCKQUOTE><H3><A NAME="Heading3"></A>Creating a Socket</H3><P>When you build applications with Visual C++, you can use the MFC Winsock classesto add network communications capabilities with relative ease. The base class, CAsyncSocket,provides complete, event-driven socket communications. You can create your own descendentsocket class that captures and responds to each of these events.</P><BLOCKQUOTE>	<P><HR><STRONG>CAUTION:</STRONG> This discussion of socket communications assumes that you check	the AppWizard option for adding support for Windows Sockets. This adds supporting	functionality to the application that is not discussed here.<HR></BLOCKQUOTE><P><A HREF="javascript:popUp('20fig02.gif')"><B>FIGURE 20.2.</B></A><B> </B><I>Portsare used to route network communications to the correct application.</I></P><P>To create a socket that you can use in your application, the first thing you needto do is declare a variable of CAsyncSocket (or your descendent class) as a classmember for one of the main application classes:</P><P><PRE>class CMyDlg : public CDialog{...private:    CAsyncSocket m_sMySocket;};</PRE><P>Before you can begin using the socket object, you must call its Create method.This actually creates the socket and prepares it for use. How you call the Createmethod depends on how you will be using the socket. If you will be using the socketto connect to another application, as the one placing the call (the client), thenyou do not need to pass any parameters to the Create method:</P><P><PRE>if (m_sMySocket.Create()){    // Continue on}else    // Perform error handling here</PRE><P>However, if the socket is going to be listening for another application to connectto it, waiting for the call (the server), then you need to pass at least the portnumber on which the socket should be listening:</P><P><PRE>if (m_sMySocket.Create(4000)){    // Continue on}else    // Perform error handling here</PRE><P>You can include other parameters in the Create method call, such as the type ofsocket to create, the events that the socket should respond to, and the address thatthe socket should listen on (in case the computer has more than one network card).All these options require a more thorough understanding of sockets than we'll beable to cover today.</P><P><H3><A NAME="Heading4"></A>Making a Connection</H3><P>Once you create a socket, you are ready to open a connection with it. Three stepsgo along with opening a single connection. Two of these steps take place on the server,the application listing for the connection, and the third step takes place on theclient, the one making the call.</P><P>For the client, opening the connection is a simple matter of calling the Connectmethod. The client has to pass two parameters to the Connect method: the computername, or network address, and the port of the application to connect to. The Connectmethod could be used in the following two ways:</P><P><PRE>if (m_sMySocket.Connect(&quot;thatcomputer.com&quot;, 4000)){    // Continue on}else    // Perform error handling here</PRE><P>The second form is</P><P><PRE>if (m_sMySocket.Connect(&quot;178.1.25.82&quot;, 4000)){    // Continue on}else    // Perform error handling here</PRE><P>Once the connection is made, an event is triggered to let your application knowthat it is connected or that there were problems and the connection couldn't be made.(I'll cover how these events work in the section &quot;Socket Events,&quot; laterin this chapter.)</P><P>For the server, or listening, side of the connection, the application first musttell the socket to listen for incoming connections by calling the Listen method.The Listen method takes only a single argument, which you do not need to supply.This parameter specifies the number of pending connections that can be queued, waitingfor the connection to be completed. By default this value is 5, which is the maximum.The Listen method can be called as follows:</P><P><PRE>if (m_sMySocket.Listen()){    // Continue on}else    // Perform error handling here</PRE><P>Whenever another application is trying to connect to the listening application,an event is triggered to let the application know that the connection request isthere. The listening application must accept the connection request by calling theAccept method. This method requires the use of a second CAsyncSocket variable, whichis connected to the other application. Once a socket is placed into listen mode,it stays in listen mode. Whenever connection requests are received, the listeningsocket creates another socket, which is connected to the other application. Thissecond socket should not have the Create method called for it because the Acceptmethod creates the socket. You call the Accept method as follows:</P><P><PRE>if (m_sMySocket.Accept(m_sMySecondSocket)){

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
午夜精品成人在线视频| 中文字幕精品在线不卡| 久久久久久97三级| 中文字幕一区二区三区在线播放| 亚洲午夜电影在线| 精品亚洲成a人在线观看| 波多野结衣在线一区| 欧美性大战久久| 久久综合精品国产一区二区三区| 亚洲欧美综合色| 日韩成人一级大片| hitomi一区二区三区精品| 欧美日韩一区二区在线视频| 久久综合色婷婷| 亚洲综合在线视频| 韩国成人福利片在线播放| 97精品久久久午夜一区二区三区| 欧美群妇大交群中文字幕| 欧美国产一区二区在线观看| 香蕉加勒比综合久久| 国产99久久久久| 欧美另类久久久品| 中文子幕无线码一区tr| 日韩综合小视频| 99国产精品久久| 久久网站热最新地址| 亚洲成人第一页| 成人动漫精品一区二区| 精品久久久久久久久久久久久久久| 亚洲色图第一区| 国产毛片精品国产一区二区三区| 欧美三级乱人伦电影| 国产蜜臀av在线一区二区三区| 爽好多水快深点欧美视频| av一二三不卡影片| 久久久亚洲综合| 日韩成人免费看| 91黄色免费网站| 国产精品―色哟哟| 九九视频精品免费| 69久久夜色精品国产69蝌蚪网| 亚洲特黄一级片| 国产精品99久久久久久久女警| 91精品久久久久久蜜臀| 亚洲综合自拍偷拍| 91一区二区三区在线观看| 国产欧美精品一区二区色综合| 免费日本视频一区| 欧美人与z0zoxxxx视频| 一区二区三国产精华液| 99精品在线免费| 欧美国产精品一区二区| 精品一区二区三区香蕉蜜桃| 3d成人h动漫网站入口| 亚洲一区自拍偷拍| 91蜜桃在线免费视频| 中文字幕一区二区三区精华液 | 欧美成人精品高清在线播放| 亚洲国产cao| 欧美影视一区二区三区| 亚洲精品中文字幕乱码三区| 成人激情午夜影院| 国产精品伦一区| 国产不卡视频在线播放| 欧美激情一区二区三区在线| 国产高清一区日本| 国产亚洲一本大道中文在线| 国产综合成人久久大片91| 精品精品国产高清a毛片牛牛| 免费在线视频一区| 日韩三级中文字幕| 久久国产成人午夜av影院| 欧美精品一区二区三区很污很色的| 蜜桃一区二区三区在线观看| 日韩亚洲欧美成人一区| 丝袜美腿亚洲色图| 日韩欧美一区在线观看| 日本欧洲一区二区| 精品粉嫩超白一线天av| 久久99精品久久久久久动态图| 欧美第一区第二区| 久久se这里有精品| 欧美国产97人人爽人人喊| www.性欧美| 亚洲情趣在线观看| 欧美羞羞免费网站| 日韩精品成人一区二区三区| 3d动漫精品啪啪一区二区竹菊| 久久精品72免费观看| 久久久午夜精品| k8久久久一区二区三区| 亚洲免费观看高清完整版在线观看| 91久久久免费一区二区| 婷婷久久综合九色综合绿巨人| 日韩欧美你懂的| 成人久久18免费网站麻豆 | 欧美日韩一级黄| 日本不卡高清视频| 欧美国产视频在线| 在线免费不卡视频| 男男成人高潮片免费网站| 久久久久国产精品麻豆ai换脸| 成人免费高清在线观看| 亚洲一区二区3| 2023国产精华国产精品| 99riav一区二区三区| 日韩精品亚洲专区| 久久久精品tv| 欧美色倩网站大全免费| 久久电影国产免费久久电影| 中文在线一区二区| 欧美精品在线观看一区二区| 国产在线精品一区二区| 亚洲人成电影网站色mp4| 欧美一区二区三区小说| av在线这里只有精品| 午夜日韩在线观看| 国产偷国产偷亚洲高清人白洁| 一本一道波多野结衣一区二区| 日韩精品亚洲专区| 日韩一区中文字幕| 欧美一区日韩一区| av不卡免费电影| 免费高清成人在线| 亚洲精品一二三四区| 欧美v国产在线一区二区三区| 99国产精品视频免费观看| 麻豆精品在线视频| 亚洲精品高清视频在线观看| 日韩一级大片在线观看| 91精彩视频在线| 成人免费福利片| 麻豆国产精品官网| 一区二区欧美视频| 中文字幕免费不卡| 日韩午夜激情电影| 欧美曰成人黄网| 国产成人av电影在线观看| 日韩国产欧美一区二区三区| 亚洲欧洲日韩综合一区二区| 精品久久久久久无| 在线不卡一区二区| 色一情一乱一乱一91av| 国产精品亚洲а∨天堂免在线| 亚洲国产wwwccc36天堂| 中文字幕日韩一区| 久久理论电影网| 欧美一级免费大片| 欧美性猛交xxxx黑人交| 99视频精品在线| 国产精品夜夜嗨| 麻豆久久一区二区| 午夜电影一区二区三区| 一区二区三区国产豹纹内裤在线| 久久精品免视看| 亚洲精品一区二区三区影院 | 日本不卡123| 一区二区三区成人| 亚洲欧美另类小说| 中文字幕日韩一区| 国产日韩欧美a| 欧美大片免费久久精品三p| 欧美日韩高清一区二区不卡| 欧美影院一区二区| 色欧美片视频在线观看在线视频| 不卡视频免费播放| 成人在线综合网| 国产精品综合二区| 国产在线精品一区在线观看麻豆| 青青草97国产精品免费观看| 日日嗨av一区二区三区四区| 午夜视频在线观看一区| 一本大道久久a久久精品综合 | 中文字幕在线视频一区| 国产丝袜欧美中文另类| 久久久综合精品| 久久久精品免费网站| 久久精品人人做| 国产亚洲欧美日韩俺去了| 国产三级精品三级在线专区| 国产午夜亚洲精品不卡 | 99亚偷拍自图区亚洲| 成人国产亚洲欧美成人综合网| 成人免费av网站| 色综合久久久久| 在线观看一区不卡| 欧美男人的天堂一二区| 91精品国产一区二区人妖| 日韩欧美专区在线| 久久久亚洲高清| 中文字幕欧美国产| 自拍偷拍欧美激情| 亚洲欧美激情小说另类| 亚洲国产欧美一区二区三区丁香婷| 亚洲成人先锋电影| 精品在线观看免费| 成人性生交大合| 色综合天天综合在线视频| 在线精品亚洲一区二区不卡| 6080国产精品一区二区|