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

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

?? ch20.htm

?? 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>

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美三日本三级三级在线播放| 中文字幕第一区二区| 日本一区二区三区四区在线视频 | 欧美一区二区三区四区久久| 精品国产91久久久久久久妲己| 一区二区三区在线播| 久久99精品一区二区三区| 色av一区二区| 国产日产精品1区| 奇米影视一区二区三区小说| 在线欧美日韩国产| 国产午夜精品一区二区三区视频| 日韩av电影一区| 欧美亚洲自拍偷拍| 中文字幕日本不卡| 成人免费观看视频| 久久综合九色综合欧美亚洲| 日本不卡123| 91激情在线视频| 国产精品白丝在线| 国产福利91精品一区| 欧美日韩mp4| 亚洲一区二区视频| 色天天综合色天天久久| 中文文精品字幕一区二区| 国产一区二区三区在线看麻豆| 欧美一区午夜精品| 亚欧色一区w666天堂| 欧美亚洲国产一区在线观看网站 | 精品久久久网站| 美女尤物国产一区| 日韩精品一区二区三区视频| 天天综合日日夜夜精品| 欧美福利视频一区| 日韩激情视频网站| 日韩欧美国产综合| 精品一区二区三区免费播放| 久久尤物电影视频在线观看| 国产成人一级电影| 欧美激情综合五月色丁香| 国产69精品久久777的优势| 国产色婷婷亚洲99精品小说| 国产成人高清在线| 国产精品国产三级国产| 99re这里只有精品首页| 亚洲视频免费在线观看| 欧美三级电影一区| 男人操女人的视频在线观看欧美| 亚洲精品一区二区在线观看| 国产激情精品久久久第一区二区| 中文字幕va一区二区三区| 色综合网色综合| 亚洲国产成人av| 精品久久久久久久人人人人传媒 | 免费观看在线色综合| 欧美成人福利视频| 国产99一区视频免费| 日韩久久一区二区| 欧美日韩国产综合草草| 国模套图日韩精品一区二区| 国产精品久久久久久久久果冻传媒| 在线观看国产日韩| 丝袜美腿一区二区三区| 久久久.com| 色综合久久88色综合天天免费| 日韩va欧美va亚洲va久久| 久久网这里都是精品| 一本色道久久综合精品竹菊| 蜜臀av一区二区在线观看| 中文字幕乱码日本亚洲一区二区 | 日韩主播视频在线| 国产无人区一区二区三区| 在线一区二区三区四区五区 | 成人av电影免费在线播放| 午夜久久久久久| 国产日韩欧美综合一区| 在线观看91视频| 国产 日韩 欧美大片| 日韩福利视频网| 亚洲欧洲日韩一区二区三区| 日韩你懂的在线播放| 欧美色中文字幕| 不卡的电影网站| 久久国产日韩欧美精品| 一区二区三区高清| 久久精品在这里| 欧美一区二区三区喷汁尤物| 91影院在线免费观看| 国产一区 二区| 午夜不卡av免费| 亚洲免费视频中文字幕| 国产三区在线成人av| 日韩欧美亚洲国产精品字幕久久久| voyeur盗摄精品| 国产精品538一区二区在线| 午夜精品久久久久久久99樱桃| 中文字幕一区二区三区精华液| 精品国产亚洲在线| 日韩欧美一级二级| 日韩一区二区在线观看视频| 欧美日韩亚洲丝袜制服| 欧美在线观看18| 色婷婷亚洲精品| 粉嫩av一区二区三区粉嫩| 国产馆精品极品| 国产成人在线观看免费网站| 国内一区二区在线| 国产自产视频一区二区三区| 国内精品国产三级国产a久久| 蜜臀久久99精品久久久久久9| 日韩精品91亚洲二区在线观看| 亚洲一卡二卡三卡四卡无卡久久| 亚洲欧美日韩国产成人精品影院 | 久久综合久久综合亚洲| 欧美一区二区精品| 欧美一级专区免费大片| 7777精品伊人久久久大香线蕉最新版 | 色综合天天性综合| 97se亚洲国产综合自在线不卡| 国产成人三级在线观看| 高清不卡在线观看| 成人视屏免费看| 99re这里只有精品首页| 日本精品一级二级| 欧美性猛交xxxxxx富婆| 制服丝袜亚洲色图| 久久综合狠狠综合久久综合88 | 欧美日韩精品免费观看视频| 欧美日韩免费电影| 欧美成人福利视频| 国产日产欧产精品推荐色| ●精品国产综合乱码久久久久| 国产精品不卡一区| 亚洲成人三级小说| 日本三级韩国三级欧美三级| 久久成人麻豆午夜电影| 国产成人综合亚洲91猫咪| 成人白浆超碰人人人人| 在线免费视频一区二区| 欧美一区二区精品在线| 国产香蕉久久精品综合网| 国产精品色呦呦| 久久国产日韩欧美精品| av综合在线播放| 欧美中文字幕一区| 欧美一级一级性生活免费录像| 久久久午夜电影| 亚洲视频一区在线| 奇米色一区二区| 粉嫩高潮美女一区二区三区| 欧美在线啊v一区| 精品欧美一区二区久久| 亚洲男人的天堂一区二区| 免费在线观看一区| 不卡电影一区二区三区| 欧美高清视频不卡网| 国产精品久久久久久久久搜平片| 亚洲在线观看免费| 国产精品一区二区在线观看网站| 成人开心网精品视频| 欧美乱熟臀69xxxxxx| 欧美韩国日本一区| 欧美a级理论片| 色网站国产精品| 久久综合国产精品| 亚洲国产成人porn| 99天天综合性| 久久影院午夜论| 日韩制服丝袜av| 色婷婷久久久久swag精品 | 91国内精品野花午夜精品| 精品国产一区二区在线观看| 亚洲你懂的在线视频| 国产一区二区三区在线观看精品| 欧美日韩精品一区二区| 亚洲丝袜另类动漫二区| 国产一区视频网站| 欧美一区日韩一区| 亚洲一区二区三区四区五区中文| 国产91对白在线观看九色| 日韩欧美黄色影院| 日本特黄久久久高潮| 在线视频观看一区| 国产欧美日韩另类一区| 国精产品一区一区三区mba桃花| 在线播放中文一区| 亚洲一级片在线观看| 色成人在线视频| 17c精品麻豆一区二区免费| 国产一区日韩二区欧美三区| 精品三级在线看| 麻豆视频一区二区| 91精品欧美福利在线观看| 亚洲一区二区高清| 欧美性极品少妇| 亚洲一二三四区不卡| 欧美怡红院视频| 亚洲va韩国va欧美va| 欧美日韩成人在线一区| 丝袜美腿高跟呻吟高潮一区|