ÓÃCSocket´´½¨C/S½á¹¹
CSocketÅÉÉúÓÚCAsyncSocket, ËùÓÐÊ©ÖîÓÚÉϵIJÙ×÷½ÔΪͬ²½²Ù×÷¡£±ÈÈçConnnect,ReceiveµÈ¡£
ͬ²½²Ù×÷µÄÓŵãÊǼòµ¥Ò×Ó㬵«È±µãÒ²ÏÔ¶øÒ×¼û£¬Ð§ÂʵÍÏ£¬ÒòΪÄã±ØÐëµÈµ½Ò»¸ö²Ù×÷Íê³ÉÖ®ºó²ÅÄܽøÐÐÏÂÒ»¸ö²Ù×÷¡£
Èç¹ûÄãºÜ¹ØÐÄЧÂÊ£¬¾ÍÓ¦¸ÃÓÅÏÈʹÓÃCAsyncSocket¡£·´Ö®¾ÍÓÃCSocket¡£
ÏÂÃ潫˵Ã÷ÈçºÎÓÃCSocket´´½¨¼òµ¥µÄ·þÎñÆ÷ºÍ¿Í»§¶Ë¡£
[´´½¨·þÎñÆ÷]
·þÎñÆ÷µÄÔË×÷ÓÐ5¸ö½×¶Î:
1. ´´½¨·þÎñÆ÷Socket²¢¿ªÆô¼àÌý¡£
2. »ñȡеĿͻ§¶ËÁ¬½ÓSocket£¬½«Ö®¼ÓÈë¿Í»§¶ËSocketÁбíÒÔ¹ÜÀíÖ®¡£
3. ¿Í»§¶ËSocket¶ÁÈ¡Êý¾Ý²¢·¢ËÍÊý¾Ý¡£
4. ¿Í»§¶ËÁ¬½Ó±»¶¯¹Ø±Õ£¬´ÓÁбíɾ³ý¡£
5. ³ÌÐò¹Ø±Õ£¬½ø¶ø·þÎñÆ÷Á¬½ÓÖ÷¶¯¹Ø±Õ¡£
ΪÁËά³Ö5½×¶ÎµÄÔË×÷£¬ÐèÒªÁ½ÖÖSocketÐͬ¹¤×÷, µÚÒ»ÖÖÓÃ×÷·þÎñÆ÷¼àÌý£¨¸ºÔð²½Öè1£¬2£¬5£©£¬µÚ¶þÖÖÓÃ×÷¿Í»§¶Ë¹ÜÀí£¨¸ºÔð²½Öè3£¬4£©¡£
Á½ÖÖSocket½ÔÅÉÉú×ÔCSocket, ͨ¹ýÖØд²»Í¬µÄCSocket³ÉÔ±º¯ÊýÒÔʵÏÖ²»Í¬µÄ¹¦ÄÜ¡£
Ç°ÕßÐèÒªÔÚ·þÎñÆ÷³õʼ»¯½×¶Î´´½¨³öÀ´CSocket::Create()²¢¿ªÆô¼àÌýCSocket::Listen()£¨²½Öè1£©¡£²¢ÔÚ·þÎñÆ÷Í˳öʱÖ÷¶¯¹Ø±ÕÁ¬½ÓCSocket::Close()£¨²½Öè5£©¡£
Ç°Õß»¹ÐèÒªÖØдOnAcceptÒÔÔÚеĿͻ§¶ËÁ¬½Óµ½À´Ê±±»Í¨Öª£¬Í¬Ê±²úÉú¿Í»§¶Ë¹ÜÀíSocket£¨²½Öè2£©¡£
ºóÕßÐèÒªÖØдOnReceiveÒÔÔÚÓÐÊý¾Ýµ½À´Ê±±»Í¨Öª£¬»òÖØдOnCloseÒÔÔÚÁ¬½Ó±»¶¯¹Ø±Õ£¨¿Í»§¶Ë¹Ø±Õ£©Ê±±»Í¨Öª£¨²½Öè3£¬4£©¡£
¶ÁдÊý¾ÝÐèÒªCSocketFileÒÔ¼°CArchieveµÄÖ§³Ö¡£Ç°Õß½«CSocketµ±×÷Ò»¸öÎļþ£¬ºóÕßÔòÍê³ÉÔÚ´ËÎļþÉϵĶÁд²Ù×÷¡£
ͨ³£ÄãÐèÒªÌí¼ÓÒ»¸öCSocketFile³ÉÔ±£¬Á½¸öCArchieve³ÉÔ±£¨Ò»¸öÓÃÓÚ¶Á£¬Ò»¸öÓÃÓÚд£©£¬È»ºóÔÚSocket´´½¨Íê³Éºó³õʼ»¯ÕâЩ³ÉÔ±
socketFile_ = new CSocketFile( this ); // ÔÚarchive´´½¨³öÀ´ºó»ù±¾ÉϾͲ»ÐèÒª²Ù×÷ËûÁË£¬Ö±µ½Socket¹Ø±Õ
archiveIn_ = new CArchive( socketFile_, CArchive::load ); // ÓÃÓÚ¶Á
archiveOut_ = new CArchive( socketFile_, CArchive::store ); // ÓÃÓÚÈ¡
²¢ÔÚOnRecevieÖÐÓÃarchiveIn_¶ÁÈ¡Êý¾Ý£¬ÓÃarchiveOut_дÈëÊý¾Ý¡£ÏñÕâÑù£º
int value;
archiveIn_ >> value;
archiveOut_ << value * value;
ÏÂÃæÊDZȽÏÍêÕûµÄServer¶ËµÄÔ´´úÂë:
//---------------------------------------------------------------------------------
// CServerDoc.cpp
//---------------------------------------------------------------------------------
BOOL CServerDoc::OnNewDocument()
{
&nb
Ïà¹ØÎĵµ£º
1.int *p1 = *(int **)p2;
Õâ¸ö±í´ïʽ½«p2Ö¸ÏòµÄÖµµ±×öÖ¸ÕëÀàÐ͸³Öµ¸øp1
£¬½«ÆÕֵͨµ±×öÖ¸ÕëֵʹÓÃ
2.*£¨int **£©p1 = p2£»
Õâ¸ö±í´ïʽ½«p1Ö¸ÏòµÄÖµÐÞ¸ÄΪµÄp2±£´æµÄÖ¸Õë
µÄÖµ£¬½«Ö¸Õëµ±×öÆÕֵͨʹÓÃ
ÕâÊǽñÌì¿´us/OSµÄÄÚ´æ¹ÜÀíµÄʱºò¿´µ½µÄ£¬ÕæÊÇÌ«¾«±ÙÁË
°¦£¬¿´À´×Ô¼ºµÄ¼ûʶ»¹ÊÇÌ«ÉÙÁË£¬ÒÔºóµÃ¼Ó±¶Å ......
Õâ¸ö³ÌÐò½ö¹©±à³Ì²Î¿¼
ÈôÏëÔÚƽʱÓã¬ÇëÏÂÔØ΢ÈíµÄwallpaper changer
ÎÒÕâ¸ö³ÌÐòʵÏÖÁ˶¨Ê±¸ü»»×ÀÃæ±³¾°µÄ¹¦ÄÜ
ÃüÁîÐÐ wallpaper "your images' directory path" time_in_minute
±à³ÌÒªµã
findfirstfile findnextfile ²éÕÒͼÏñÎļþ
SystemParametersInfo ÐÞ¸ÄϵͳÐÅÏ¢£¬ÔÚÕâ¶ùµ±È»ÊÇ×ÀÃæ±³¾°
×¢²á±í²Ù×÷ ±£´æÐ ......
#include<signal.h>
#include<stdio.h>
void ctrlhandler( int a )
{
printf("you have press ctrl+c \n");
/* close Ïà¹Ø²Ù×÷*/
getchar();
exit(0);
}
int main()
{
signal(SIGINT,ctrlhandler);
/*ÆäËû²Ù×÷*/
getchar();
return 1;
} ......
½ñÌì±È½ÏÀÁ¶è£¬Ã»×öÌ⣬ֻÊÇ¿´ÁËÒ»µãÄDZ¾cÏÝÚåÓëȱÏÝ£¬ËµÊµ»°¶ÁÁ˲»¶àµ«Ã÷ÏÔÄܸоõ³öÕâÊÇÒ»±¾ºÃÊ飬¸Ð¾õ¶ÔÎÒÀ´Ëµ¸ÕºÃ£¬²»ÊÇ»ù´¡Ê飬µ«Ò²»ù±¾ÄÜ¿´¶®£¬¶øÇÒÄÜѧµ½ºÃ¶à¶«Î÷£¬µ«½ñÌìÖ»¿´ÁËÈýÕ£¬Ö÷ÒªÊÇϾüÆìÁË£¬囧£¬ÎÒÒ²Ö»ÄÜ°ÑÎÒѧµ½µÄ×ܽáÏÂÀ´£¬Ñ§ÁË×ܱÈÒ»µã¶¼Ã»Ñ§ÒªºÃ£¬ÎÒÒ²Ö»ÄÜÕâÑù°²Î¿×Ô¼ºÁË¡£ ......
1.ÒýÑÔ ±¾ÎĵÄд×÷Ä¿µÄ²¢²»ÔÚÓÚÌṩC/C++³ÌÐòÔ±ÇóÖ°ÃæÊÔÖ¸µ¼£¬¶øÖ¼ÔÚ´Ó¼¼ÊõÉÏ·ÖÎöÃæÊÔÌâµÄÄÚº¡£ÎÄÖеĴó¶àÊýÃæÊÔÌâÀ´×Ô¸÷´óÂÛ̳£¬²¿·ÖÊÔÌâ½â´ðÒ²²Î¿¼ÁËÍøÓѵÄÒâ¼û-¡£
Ðí¶àÃæÊÔÌâ¿´ËƼòµ¥£¬È´ÐèÒªÉîºñµÄ»ù±¾¹¦²ÅÄܸø³öÍêÃÀµÄ½â´ð¡£ÆóÒµÒªÇóÃæÊÔÕßдһ¸ö×î¼òµ¥µÄstrcpyº¯Êý¶¼¿É¿´³öÃæÊÔÕßÔÚ¼¼ÊõÉϾ¿¾¹´ïµ½ÁËÔ ......