ÓÃ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
Ïà¹ØÎĵµ£º
Boss˵£¬Òª¿´OpenGL£¬¿´ÁË¿ìÒ»¸öÔ£¬×ÜËã³öÁ˸öÏñÑùµÄ¶«Î÷£¬ÓÃCдÁ˸ö3DÃÔ¹¬£¬
ËäȻֻÓÐ350ÐÐ
´úÂ룬²»¹ý±ßѧ±ßд£¬×ã×ãдÁËÒ»ÖÜʱ¼ä£¬»¹ÊÇСÓгɾ͸еģ¬»î»î»î£¡
&n ......
1.int *p1 = *(int **)p2;
Õâ¸ö±í´ïʽ½«p2Ö¸ÏòµÄÖµµ±×öÖ¸ÕëÀàÐ͸³Öµ¸øp1
£¬½«ÆÕֵͨµ±×öÖ¸ÕëֵʹÓÃ
2.*£¨int **£©p1 = p2£»
Õâ¸ö±í´ïʽ½«p1Ö¸ÏòµÄÖµÐÞ¸ÄΪµÄp2±£´æµÄÖ¸Õë
µÄÖµ£¬½«Ö¸Õëµ±×öÆÕֵͨʹÓÃ
ÕâÊǽñÌì¿´us/OSµÄÄÚ´æ¹ÜÀíµÄʱºò¿´µ½µÄ£¬ÕæÊÇÌ«¾«±ÙÁË
°¦£¬¿´À´×Ô¼ºµÄ¼ûʶ»¹ÊÇÌ«ÉÙÁË£¬ÒÔºóµÃ¼Ó±¶Å ......
Á´±íÊÇcÓïÑÔÖкÜÖØÒªµÄÊý¾Ý½á¹¹£¬ÊÇ¿¼²ìÒ»¸ö³ÌÐòÔ±µÄ»ù±¾¹¦µÄÊֶΣ¬Ö®Ç°ÔÚÒ»¼Ò¹«Ë¾ÃæÊÔʱ¾ÍÎʵ½ÁË
ʵÏÖÒ»¸öÁ´±íµÄ·´×ª£¬µ±Ê±¾ÍÊÇûÓкܺÃÀä¾²µÄ˼¿¼£¬½ñÌìÔÚÕâÀïд³öÀ´£¬¹²Ã㣡
»ù±¾Ëã·¨£º
1. ÅжÏÊÇ·ñΪ¿Õ£¬Èç¹ûΪ¿Õ£¬·µ»ØNULL
  ......
Chapter 1: Thread
¢Ù thread functions
1. pthread_self();
2. thread existing
you can get the value of rval_ptr just by pthread_join(pthread_t tht, void ** rval_ptr)
cancel a thread as the thread exits with PTHREAD_CANCELED in pthread_exit, this functio ......
·¢ÌùÇ°ÇëÏȶÁ£ºc/c++ °æ“¾µä”ÎÊÌâ½â´ð
C/C++Ò»Ö±¶¼ÊǵØÇòÉÏʹÓÃ×î¹ã·ºµÄ±à³ÌÓïÑÔ£¬¶øÎÒÃǵÄC/C++°æ×ÔÈ»ÈËÆøÒ²²»²î£¬µ«ÊÇÒ»Ö±¶¼ÓÐһЩºÝ³õ¼¶µÄÎÊÌâÌáÁËÓÖÌᣬ²¢²»ÊÇ˵ÕâЩÎÊÌâÈçºÎÈçºÎµÄ²»ºÃ£¬»¹ÊÇÈçºÎÈçºÎµÄÈõÖÇ£¬ÕâЩÎÊÌâÒ»Ö±¶¼ÊÇÐÂÊÖѧϰµÄ»ù´¡£¬ÊDZØÐëÒª¾¹ýµÄÃż÷£¬ËùÒÔÒ²ÓдæÔڵıØÒª£¬µ«ÊÇÌáµÄ¶àÁË£¬ ......