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

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

?? ch20.htm

?? 好的教程Vc++21 天
?? 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一区二区三区免费野_久草精品视频
久久综合色婷婷| 国产成a人无v码亚洲福利| 69堂精品视频| 日产欧产美韩系列久久99| 精品一区二区三区在线视频| 高清国产午夜精品久久久久久| 色婷婷一区二区| 精品免费国产一区二区三区四区| 亚洲色图19p| 国产麻豆视频一区二区| 91精品在线麻豆| 国产精品久久久久婷婷二区次| 日本中文在线一区| 色呦呦国产精品| 欧美国产日韩亚洲一区| 精品一区二区三区在线观看| 欧美少妇xxx| 亚洲乱码国产乱码精品精小说| 国产一区二区三区在线观看免费视频| 欧美日韩精品一区视频| 欧美日韩中文字幕精品| 久久丁香综合五月国产三级网站| eeuss鲁片一区二区三区在线看| 日韩午夜小视频| 日韩专区一卡二卡| 欧美日韩国产首页| 亚洲综合图片区| 一本色道久久综合狠狠躁的推荐| 国产亚洲美州欧州综合国| 日本欧美肥老太交大片| 欧美日韩一区久久| 亚洲国产一区二区在线播放| 色94色欧美sute亚洲13| 亚洲裸体xxx| 在线亚洲人成电影网站色www| 亚洲欧美影音先锋| 91老师片黄在线观看| 1000部国产精品成人观看| 成人精品国产一区二区4080| 久久精品免视看| 成人午夜视频福利| 国产精品久久久久永久免费观看 | 欧美久久一二三四区| 伊人婷婷欧美激情| 欧美色爱综合网| 婷婷成人激情在线网| 欧美一区2区视频在线观看| 日本成人在线网站| 精品国产一区二区三区忘忧草| 捆绑调教美女网站视频一区| 久久伊人中文字幕| av亚洲精华国产精华精| 亚洲精品国产a久久久久久| 91浏览器在线视频| 午夜精品久久久久久久久久久 | 99re这里只有精品首页| 亚洲免费色视频| 欧美一区二区久久| 国产成人综合精品三级| 亚洲欧美在线aaa| 成人在线综合网站| 日韩一区二区三区观看| 国产在线精品免费av| 国产精品欧美综合在线| 欧美在线观看视频一区二区| 三级亚洲高清视频| 国产无遮挡一区二区三区毛片日本| 成人久久视频在线观看| 亚洲综合色区另类av| 日韩女优av电影| 97久久超碰国产精品电影| 日本亚洲一区二区| 中文字幕在线一区免费| 欧美一区二区三区免费视频| 懂色av一区二区在线播放| 亚洲国产精品久久人人爱蜜臀 | 欧美日韩中文字幕一区| 国内精品伊人久久久久影院对白| 日韩一区欧美一区| 精品国产髙清在线看国产毛片 | 精品国产凹凸成av人网站| 亚洲男人电影天堂| 日韩欧美精品在线| 99久免费精品视频在线观看| 麻豆精品蜜桃视频网站| 亚洲日本乱码在线观看| 亚洲精品一区二区三区蜜桃下载| 色婷婷亚洲精品| 国产高清无密码一区二区三区| 午夜精品福利一区二区蜜股av| 国产日韩欧美精品综合| 欧美一级二级三级乱码| 色一情一乱一乱一91av| 国产成人免费在线视频| 免费不卡在线观看| 亚洲一区二区三区免费视频| 国产精品国产精品国产专区不蜜| 久久综合久久综合亚洲| 欧美精品在线观看播放| 91麻豆精品一区二区三区| 国产精品99久久久久久有的能看| 五月天亚洲婷婷| 亚洲综合小说图片| 亚洲自拍欧美精品| 亚洲精品成人a在线观看| 亚洲欧洲av色图| 国产精品高潮呻吟久久| 中文字幕欧美三区| 国产午夜精品久久| 国产午夜精品一区二区| 国产欧美中文在线| 国产婷婷一区二区| 久久精品日产第一区二区三区高清版| 欧美tk—视频vk| 欧美电影免费观看完整版| 欧美一级免费大片| 日韩午夜av电影| 日韩欧美中文字幕一区| 欧美电影免费观看高清完整版在 | 亚洲色图19p| 一区二区三区四区蜜桃 | 色综合久久久久综合99| 99精品视频在线免费观看| 91一区一区三区| 91福利区一区二区三区| 欧美综合天天夜夜久久| 欧美日韩三级一区| 91麻豆精品国产自产在线观看一区| 欧美日韩精品一区视频| 欧美一区二区三区四区五区| 日韩欧美在线影院| 国产亚洲人成网站| 中文字幕av一区 二区| 亚洲免费色视频| 日韩在线卡一卡二| 国产在线观看免费一区| 国产69精品久久久久777| 99精品国产视频| 欧美色区777第一页| 日韩午夜三级在线| 国产精品亲子伦对白| 亚洲亚洲人成综合网络| 久久精品国产在热久久| 亚洲国产日韩在线一区模特| 日韩中文字幕一区二区三区| 韩国精品在线观看| 91欧美激情一区二区三区成人| 日本高清无吗v一区| 日韩精品中午字幕| 中文字幕永久在线不卡| 石原莉奈在线亚洲三区| 国产一区二区在线电影| 99综合电影在线视频| 欧美高清视频www夜色资源网| 久久丝袜美腿综合| 一区二区三区毛片| 国产一区不卡精品| 在线免费亚洲电影| 久久久久9999亚洲精品| 亚洲二区在线视频| 国产麻豆午夜三级精品| 欧美人体做爰大胆视频| 国产日韩成人精品| 午夜在线成人av| 香蕉影视欧美成人| 国产精品一区二区无线| 色欧美片视频在线观看| 久久久久久久综合| 调教+趴+乳夹+国产+精品| 成人不卡免费av| 精品国产91九色蝌蚪| 亚洲一区二区三区四区中文字幕| 国产又粗又猛又爽又黄91精品| 在线观看网站黄不卡| 中文无字幕一区二区三区| 精品日本一线二线三线不卡| 欧美国产精品专区| 久久精品国产一区二区三| 欧美性色欧美a在线播放| 国产精品久99| 国产真实精品久久二三区| 884aa四虎影成人精品一区| 亚洲嫩草精品久久| 成人精品免费网站| 久久精品一区二区| 精品无人区卡一卡二卡三乱码免费卡| 欧美日韩在线直播| 亚洲精品高清在线| 91极品美女在线| 亚洲理论在线观看| 91亚洲精品久久久蜜桃| 国产精品国产馆在线真实露脸| 东方aⅴ免费观看久久av| 日韩免费高清电影| 久久激五月天综合精品| 日韩亚洲电影在线| 激情伊人五月天久久综合| 精品处破学生在线二十三| 精品一区二区三区久久久| 欧美不卡一二三|