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

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

?? ch20.htm

?? 21天學(xué)會VC的英文版
?? HTM
?? 第 1 頁 / 共 4 頁
字號:
    // Continue on}else    // Perform error handling here</PRE><P>At this point, the connecting application is connected to the second socket onthe listening application.</P><P><H3><A NAME="Heading5"></A>Sending and Receiving Messages</H3><P>Sending and receiving message through a socket connection gets slightly involved.Because you can use sockets to send any kind of data, and they don't care what thedata is, the functions to send and receive data expect to be passed a pointer toa generic buffer. For sending data, this buffer should contain the data to be sent.For receiving data, this buffer will have the received data copied into it. As longas you are sending and receiving strings and text, you can use fairly simple conversionsto and from CStrings with these buffers.</P><P>To send a message through a socket connection, you use the Send method. This methodrequires two parameters and has a third, optional parameter that can be used to controlhow the message is sent. The first parameter is a pointer to the buffer that containsthe data to be sent. If your message is in a CString variable, you can use the LPCTSTRoperator to pass the CString variable as the buffer. The second parameter is thelength of the buffer. The method returns the amount of data that was sent to theother application. If an error occurs, the Send function returns SOCKET_ERROR. Youcan use the Send method as follows:</P><P><PRE>CString strMyMessage;int iLen;int iAmtSent;...iLen = strMyMessage.GetLength();iAmtSent = m_sMySocket.Send(LPCTSTR(strMyMessage), iLen);if (iAmtSent == SOCKET_ERROR){    // Do some error handling here}else{    // Everything's fine}</PRE><P>When data is available to be received from the other application, an event istriggered on the receiving application. This lets your application know that it canreceive and process the message. To get the message, the Receive method must be called.This method takes the same parameters as the Send method with a slight difference.The first parameter is a pointer to a buffer into which the message may be copied.The second parameter is the size of the buffer. This tells the socket how much datato copy (in case more is received than will fit into the buffer). Like the Send method,the Receive method will return the amount that was copied into the buffer. If anerror occurs, the Receive method also returns SOCKET_ERROR. If the message your applicationis receiving is a text message, it can be copied directly into a CString variable.This allows you to use the Receive method as follows:</P><P><PRE>char *pBuf = new char[1025];int iBufSize = 1024;int iRcvd;CString strRecvd;iRcvd = m_sMySocket.Receive(pBuf, iBufSize);if (iRcvd == SOCKET_ERROR){    // Do some error handling here}else{    pBuf[iRcvd] = NULL;    strRecvd = pBuf;    // Continue processing the message}</PRE><BLOCKQUOTE>	<P><HR><STRONG>TIP:</STRONG> When receiving text messages, it's always a good idea to place a NULL	in the buffer position just after the last character received, as in the preceding	example. There may be garbage characters in the buffer that your application might	interpret as part of the message if you don't add the NULL to truncate the string.<HR>	<P><HR><STRONG>NOTE:</STRONG> The Close function is one of the few CAsyncSocket methods that does	not return any status code. For all the previous member functions that we have examined,	you can capture the return value to determine if an error has occurred.<HR></BLOCKQUOTE><H3><A NAME="Heading6"></A>Closing the Connection</H3><P>Once your application has finished all of its communications with the other application,it can close the connection by calling the Close method. The Close method doesn'ttake any parameters, and you use it as follows:</P><P><PRE>m_sMySocket.Close();</PRE><H3><A NAME="Heading7"></A>Socket Events</H3><P>The primary reason that you create your own descendent class of CAsyncSocket isthat you want to capture the events that are triggered when messages are received,connections are completed, and so on. The CAsyncSocket class has a series of functionsthat are called for each of these various events. These functions all use the samedefinition--the function name is the only difference--and they are intended to beoverridden in descendent classes. All of these functions are declared as protectedmembers of the CAsyncSocket class and probably should be declared as protected inyour descendent classes. The functions all have a single integer parameter, whichis an error code that should be checked to make sure that no error has occurred.Table 20.1 lists these event functions and the events they signal.</P><P><H4>TABLE 20.1. CAsyncSocket OVERRIDABLE EVENT-NOTIFICATION FUNCTIONS.</H4><P><TABLE BORDER="1">	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT"><I>Function</I></TD>		<TD ALIGN="LEFT"><I>Event Description</I></TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">OnAccept		</TD>		<TD ALIGN="LEFT">This function is called on a listening socket to signal that a connection request			from another application is waiting to be accepted.		</TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">OnClose		</TD>		<TD ALIGN="LEFT">This function is called on a socket to signal that the application on the other end			of the connection has closed its socket or that the connection has been lost. This			should be followed by closing the socket that received this notification.		</TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">OnConnect		</TD>		<TD ALIGN="LEFT">This function is called on a socket to signal that the connection with another application			has been completed and that the application can now send and receive messages through			the socket.		</TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">OnReceive		</TD>		<TD ALIGN="LEFT">This function is called to signal that data has been received through the socket			connection and that the data is ready to be retrieved by calling the Receive function.		</TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">OnSend		</TD>		<TD ALIGN="LEFT">This function is called to signal that the socket is ready and available for sending			data. This function is called right after the connection has been completed. Usually,			the other time that this function is called is when your application has passed the			Send function more data than can be sent in a single packet. In this case, this is			a signal that all of the data has been sent, and the application can send the next			buffer-full of data.		</TD>	</TR></TABLE><H3><A NAME="Heading8"></A>Detecting Errors</H3><P>Whenever any of the CAsyncSocket member functions return an error, either FALSEfor most functions or SOCKET_ERROR on the Send and Receive functions, you can callthe GetLastError method to get the error code. This function returns only error codes,and you have to look up the translation yourself. All the Winsock error codes aredefined with constants, so you can use the constants in your code to determine theerror message to display for the user, if any. You can use the GetLastError functionas follows:</P><P><PRE>int iErrCode;iErrCode = m_sMySocket.GetLastError();switch (iErrCode){case WASNOTINITIALISED:...}</PRE><H2><A NAME="Heading9"></A>Building a Networked Application</H2><P>For the sample application that you will build today, you'll create a simple dialogapplication that can function as either the client or server in a Winsock connection.This will allow you to run two copies of the sample application, one for each endof the connection, on the same computer or to copy the application to another computerso that you can run the two copies on separate computers and see how you can passmessages across a network. Once the application has established a connection withanother application, you will be able to enter text messages and send them to theother application. When the message has been sent, it will be added to a list ofmessages sent. Each message that is received will be copied into another list ofall messages received. This will allow you to see the complete list of what is sentand received. It will also allow you to compare what one copy of the applicationhas sent and what the other has received. (The two lists should be the same.)</P><P><H3><A NAME="Heading10"></A>Creating the Application Shell</H3><P>For today's sample application, just to keep things simple, you'll create a dialog-styleapplication. Everything that you are doing in today's application can be done inan SDI or MDI application just as easily as with a dialog-style application. By usinga dialog-style application today, we are getting everything that might distract fromthe basic socket functionality (such as questions about whether the socket variablebelongs in the document or view class, how much of the application functionalitybelongs in which of these two classes, and so on) away from the sample application.</P><P>To start today's sample application, create a new MFC AppWizard project, givingthe project a suitable name, such as Sock. On the first step of the AppWizard, specifythat the application will be a dialog-based application. On the second step of theAppWizard, specify that the application should include support for Windows Sockets,as in Figure 20.3. You can accept the default settings for the rest of the optionsin the AppWizard.</P><P><H3><B>Window Layout and Startup Functionality</B></H3><P>Once you create your application shell, you can lay out the main dialog for yourapplication. On this dialog, you'll need a set of radio buttons to specify whetherthe application is running as the client or server. You'll also need a couple ofedit boxes for the computer name and port that the server will be listening on. Next,you'll need a command button to start the application listening on the socket oropening the connection to the server, and a button to close the connection. You'llalso need an edit box for entering the message to be sent to the other applicationand a button to send the message. Finally, you'll need a couple of list boxes intowhich you can add each of the messages sent and received. Place all these controlson the dialog, as shown in Figure 20.4, setting all of the control properties asspecified in Table 20.2.</P><P><A HREF="javascript:popUp('20fig03.gif')"><B>FIGURE 20.3.</B></A><B> </B><I>Includingsockets support.</I></P><P><A HREF="javascript:popUp('20fig04.gif')"><B>FIGURE 20.4.</B></A><B> </B><I>Themain dialog layout.</I></P><P><I></I><H4>TABLE 20.2. CONTROL PROPERTY SETTINGS.</H4><P><TABLE BORDER="1">	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT"><I>Object</I></TD>		<TD ALIGN="LEFT"><I>Property</I></TD>		<TD ALIGN="LEFT"><I>Setting</I></TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">Group Box		</TD>		<TD ALIGN="LEFT">ID		</TD>		<TD ALIGN="LEFT">IDC_STATICTYPE		</TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">			<P>		</TD>		<TD ALIGN="LEFT">Caption		</TD>		<TD ALIGN="LEFT">Socket Type		</TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">Radio Button		</TD>		<TD ALIGN="LEFT">ID		</TD>		<TD ALIGN="LEFT">IDC_RCLIENT		</TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">			<P>		</TD>		<TD ALIGN="LEFT">Caption		</TD>		<TD ALIGN="LEFT">&amp;Client		</TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">			<P>		</TD>		<TD ALIGN="LEFT">Group		</TD>		<TD ALIGN="LEFT">Checked		</TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">Radio Button		</TD>		<TD ALIGN="LEFT">ID		</TD>		<TD ALIGN="LEFT">IDC_RSERVER		</TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">			<P>		</TD>		<TD ALIGN="LEFT">Caption		</TD>		<TD ALIGN="LEFT">&amp;Server		</TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">Static Text		</TD>		<TD ALIGN="LEFT">ID		</TD>		<TD ALIGN="LEFT">IDC_STATICNAME		</TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">			<P>		</TD>		<TD ALIGN="LEFT">Caption		</TD>		<TD ALIGN="LEFT">Server &amp;Name:		</TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">Edit Box		</TD>		<TD ALIGN="LEFT">ID		</TD>		<TD ALIGN="LEFT">IDC_ESERVNAME		</TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">Static Text		</TD>		<TD ALIGN="LEFT">ID		</TD>		<TD ALIGN="LEFT">IDC_STATICPORT		</TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">			<P>		</TD>		<TD ALIGN="LEFT">Caption		</TD>		<TD ALIGN="LEFT">Server &amp;Port:		</TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">Edit Box		</TD>		<TD ALIGN="LEFT">ID		</TD>		<TD ALIGN="LEFT">IDC_ESERVPORT		</TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">Command Button		</TD>		<TD ALIGN="LEFT">ID		</TD>		<TD ALIGN="LEFT">IDC_BCONNECT		</TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">			<P>		</TD>		<TD ALIGN="LEFT">Caption		</TD>		<TD ALIGN="LEFT">C&amp;onnect		</TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">Command Button		</TD>		<TD ALIGN="LEFT">ID		</TD>		<TD ALIGN="LEFT">IDC_BCLOSE		</TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">			<P>		</TD>		<TD ALIGN="LEFT">Caption		</TD>		<TD ALIGN="LEFT">C&amp;lose		</TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">			<P>		</TD>		<TD ALIGN="LEFT">Disabled		</TD>		<TD ALIGN="LEFT">Checked		</TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">Static Text		</TD>		<TD ALIGN="LEFT">ID		</TD>		<TD ALIGN="LEFT">IDC_STATICMSG		</TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">			<P>		</TD>		<TD ALIGN="LEFT">Caption		</TD>		<TD ALIGN="LEFT">&amp;Message:		</TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">			<P>

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人妖精视频yjsp地址| 欧美一级一级性生活免费录像| 一区二区在线看| 日韩欧美一二三| 91香蕉国产在线观看软件| 美女在线视频一区| 亚洲精品乱码久久久久久黑人| 久久免费午夜影院| 3d成人动漫网站| 色哟哟在线观看一区二区三区| 国产精品资源站在线| 亚洲福利电影网| 亚洲丝袜美腿综合| 久久久99精品久久| 日韩欧美电影在线| 欧美日韩成人综合在线一区二区| 波多野结衣一区二区三区| 久久国内精品视频| 日本免费新一区视频| 亚洲国产一二三| 一级中文字幕一区二区| 亚洲视频资源在线| 国产精品久久二区二区| 中文字幕欧美激情| 久久久久国产免费免费| 精品久久一区二区三区| 欧美一区二区网站| 欧美丰满高潮xxxx喷水动漫| 欧美无砖专区一中文字| 欧美视频一区二区三区四区 | 青青草视频一区| 午夜欧美一区二区三区在线播放| 亚洲欧美偷拍另类a∨色屁股| 国产精品久久久久影院色老大| 日本一二三四高清不卡| 国产精品视频yy9299一区| 国产婷婷色一区二区三区| 久久蜜臀精品av| 国产日韩欧美精品电影三级在线| 久久精品亚洲一区二区三区浴池| 久久综合av免费| 久久久国产精品不卡| 国产亚洲制服色| 欧美国产日本视频| 国产精品毛片高清在线完整版| 国产精品欧美久久久久无广告| 中文字幕欧美日本乱码一线二线| 国产精品久久久久久久久搜平片| 国产精品久久毛片a| 亚洲少妇中出一区| 一区二区三区国产豹纹内裤在线 | 亚洲综合色噜噜狠狠| 亚洲成人免费在线| 久久精品免费观看| 国产成人免费视频网站| av在线不卡免费看| 91成人在线免费观看| 91精品国产综合久久精品图片| 日韩欧美123| 国产精品天天摸av网| 亚洲免费高清视频在线| 亚洲福利一二三区| 老汉av免费一区二区三区| 国产一区二区h| 97国产一区二区| 欧美久久久久久久久久| 久久伊99综合婷婷久久伊| 国产精品久久久久7777按摩 | 国产成人三级在线观看| 99久久精品免费看| 欧美精品乱人伦久久久久久| 久久麻豆一区二区| 亚洲乱码一区二区三区在线观看| 午夜精品久久久久久久蜜桃app| 毛片不卡一区二区| 波多野结衣中文一区| 欧美日本一区二区在线观看| 精品国产sm最大网站免费看| 国产精品嫩草99a| 日韩不卡在线观看日韩不卡视频| 国产成人综合亚洲91猫咪| 色老综合老女人久久久| 精品国产网站在线观看| 亚洲嫩草精品久久| 久久国内精品视频| 在线亚洲一区观看| 精品国产1区二区| 一区二区成人在线| 国产精品亚洲专一区二区三区| 欧洲日韩一区二区三区| 国产午夜精品一区二区三区嫩草| 一区二区视频免费在线观看| 狠狠色丁香久久婷婷综合_中| 欧美性生活久久| 中文字幕不卡的av| 日韩电影一二三区| 91麻豆福利精品推荐| 国产亚洲综合在线| 日韩黄色免费网站| 日本精品一区二区三区高清| 久久综合九色欧美综合狠狠 | 亚洲成人一区二区在线观看| 国产很黄免费观看久久| 在线播放亚洲一区| 亚洲综合免费观看高清在线观看| 粉嫩av一区二区三区粉嫩| 欧美一级视频精品观看| 亚洲精品中文字幕在线观看| 国产成人免费在线视频| 日韩免费高清视频| 日韩**一区毛片| 欧美丝袜自拍制服另类| 亚洲免费av在线| 成人a免费在线看| 国产性色一区二区| 国产一区二区三区免费在线观看| 欧美日韩精品一区二区| 亚洲一区二区三区四区的| 91蜜桃婷婷狠狠久久综合9色| 国产欧美一区二区精品久导航| 久久国产三级精品| 日韩一卡二卡三卡四卡| 性做久久久久久免费观看欧美| 91福利在线免费观看| 亚洲美腿欧美偷拍| bt7086福利一区国产| 国产精品福利在线播放| 成人91在线观看| 亚洲国产高清aⅴ视频| 国产精品99久久久| 中文字幕欧美三区| www.亚洲在线| 亚洲人成在线播放网站岛国 | 亚洲精品在线免费播放| 极品少妇一区二区| 2022国产精品视频| 国产精品一级二级三级| 欧美经典一区二区| 成人久久18免费网站麻豆 | 国产99久久久国产精品免费看| 精品蜜桃在线看| 国产精品一区二区91| 欧美高清在线精品一区| 99国产精品久久| 亚洲妇熟xx妇色黄| 欧美一级搡bbbb搡bbbb| 精品在线免费观看| 久久久久久久久久美女| 成人精品免费看| 一区二区三区中文在线| 欧美日韩大陆在线| 黑人精品欧美一区二区蜜桃| 久久久电影一区二区三区| av综合在线播放| 亚洲一区视频在线| 欧美va天堂va视频va在线| 国产在线一区观看| 亚洲日本丝袜连裤袜办公室| 欧美性xxxxxxxx| 久久精品久久精品| 欧美国产一区二区在线观看| 色综合天天综合| 日韩精品电影在线观看| 欧美videos大乳护士334| 99久久精品免费看国产| 香蕉久久一区二区不卡无毒影院| 精品久久人人做人人爰| av午夜精品一区二区三区| 午夜精品免费在线| 欧美激情一区二区在线| 欧美艳星brazzers| 国产激情一区二区三区四区| 一区二区三区国产精华| 精品999在线播放| 91理论电影在线观看| 麻豆国产精品视频| 亚洲美女屁股眼交| 精品久久久网站| 色丁香久综合在线久综合在线观看| 免费高清成人在线| 亚洲欧美一区二区三区国产精品| 欧美一区二区人人喊爽| av不卡在线播放| 蜜臂av日日欢夜夜爽一区| 亚洲视频免费在线观看| 精品福利一区二区三区| 欧美视频第二页| 高清不卡一区二区| 免费成人在线观看| 夜夜精品浪潮av一区二区三区| 亚洲精品在线观看网站| 欧美日韩亚洲综合在线 | 国产·精品毛片| 日本亚洲电影天堂| 亚洲精品欧美激情| 久久久国产精品午夜一区ai换脸| 欧美日韩免费一区二区三区 | 中日韩免费视频中文字幕| 91精品国产色综合久久久蜜香臀| 99精品久久只有精品|