Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

ÓÃCSocket¹¹½¨C/S½á¹¹

תÌûhttp://www.cppblog.com/bidepan2023/archive/2008/01/22/41632.html
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
//-----------------------------------------------------------------------


Ïà¹ØÎĵµ£º

MATLABÓëC/C++»ìºÏ±à³ÌÖ®MATLABµ÷ÓÃC³ÌÐò

ͨ¹ý°ÑºÄʱ³¤µÄº¯ÊýÓÃcÓïÑÔʵÏÖ£¬²¢±àÒë³Émexº¯Êý¿ÉÒÔ¼Ó¿ìÖ´ÐÐËٶȡ£Matlab±¾ÉíÊDz»´øcÓïÑԵıàÒëÆ÷µÄ£¬ËùÒÔÒªÇóÄãµÄ»úÆ÷ÉÏÒѾ­°²×°ÓÐVC,BC»òWatcom CÖеÄÒ»ÖÖ¡£Èç¹ûÄãÔÚ°²×°MatlabʱÒѾ­ÉèÖùý±àÒëÆ÷£¬ÄÇôÏÖÔÚÄãÓ¦¸Ã¾Í¿ÉÒÔʹÓÃmexÃüÁîÀ´±àÒëcÓïÑԵijÌÐòÁË¡£Èç¹ûµ±Ê±Ã»ÓÐÑ¡£¬¾ÍÔÚMatlabÀï¼üÈëmex -setup£¬ÏÂÃæÖ»Òª¸ù¾ÝÌáʾ ......

CÍ·Îļþ±àдԭÔò

ÔÚʹÓÃCÓïÑÔ±àд´óÐ͹¤³ÌʱҪÓõ½ÃæÏò¶ÔÏóÓïÑÔÖеÄһЩÌØÐÔ£¨ÄÚºËÖÐijЩ²¿·Ö¾ÍÓ¦ÓÃÁËÕâЩÌØÐÔ£©¡£CÓïÑÔÊÇ»ùÓÚÎļþµÄÀ࣬static¹Ø¼ü×ÖÉùÃ÷˽ÓÐÊý¾Ý³ÉÔ±£¬¹«ÓÐÊý¾Ý³ÉÔ±±ØÐ붨Ò嵽ͷÎļþ£¬»òÓÉÆäËüÎļþʹÓÃextern¹Ø¼ü×ÖÉùÃ÷À´Ê¹Óᣵ«ºóÕßÒýÓùØϵ²»ÇåÎú¡£Í·Îļþ¾Í³ÉÁ˹«ÓÐÊý¾Ý³ÉÔ±ÉùÃ÷µÄµØ·½¡£
Í·ÎļþÖÐÓ¦¸Ã°üº¬ÒÔϼ°·½ÃæÄÚ ......

CµÄº¯ÊýÖ¸ÕëʵÏÖC++µÄ¶à̬

CµÄº¯ÊýÖ¸ÕëºÜÇ¿´ó£¬ÓúÃÁ˲ÅÊÇCÓïÑԵĸßÊÖ¡£ÏñGtkÖеĻص÷º¯ÊýµÄʹÓ㬶¼ÌåÏÖÁ˺¯ÊýÖ¸ÕëµÄÇ¿´óÍþÁ¦¡£
struct Point{
int x, y;
};
/*Shape*/
/*----------------------------------------------------------------*/
struct Shape {
struct Methods* methods;
};

struct Meth ......

£¨c primer plusµÚÎå°æ£©Ñ§Ï°±Ê¼Ç

 
 
µÚÒ»Õ¸ÅÀÀ
CÊÇÒ»ÖÖ±àÒëÐ͵ÄÓïÑÔ
±àÒëÐÍ£º¾ÍÊÇ°ÑcÓïÑÔ±àÒë³É¼ÆËã»úÄÜÔËÐеĻúÆ÷´úÂë
²»Í¬µÄ¼ÆËã»úϵͳÓÐן÷×ԵıàÒëÆ÷£¬À´°Ñc±àÒë³É¶ÔÓ¦µÄ»úÆ÷´úÂë
ÌØÐÔ£º´úÂë¸ßЧ£¬¿ÉÒÆÖ²£¬¹¦ÄÜÇ¿´óºÍÁé»î
ȱµã£º´úÂë¸ñʽ×ÔÓÉ£¨ÌرðÊÇÖ¸ÕëµÄʹÓã©
 
CÓïÑÔÔËÐеÄÆ߸ö²½Ö裺
1.     ¶¨Ò ......

cʵÏÖµÄÇóÁ½¸öÊýµÄ³Ë·¨ÄæÔª

¶¨Ò壺Éèa¶ÔbµÄ³Ë·¨ÄæÔªÊÇxÔò¿ÉÒÔ¼ÇΪa*x=1 mod b£¬¼´aºÍxµÄ»ý³ýÒÔbµÄÓàÊýÊÇ1£»
 
³Ë·¨ÄæÔª³£ÓÃËã·¨ÊÇÅ·¼¸ÀïµÂËã·¨£º
 
//Ëã·¨Çód¹ØÓÚÄ£fµÄ³Ë·¨ÄæÔªd-1 £¬¼´ d* d-1 mod f = 1
 
¡¡¡¡1 ¡£(X1£¬X2£¬X3) := (1£¬0£¬f)£» (Y1£¬Y2£¬Y3) := (0£¬1£¬d)
¡¡¡¡2¡£ if (Y3=0) then return d-1 = null //ÎÞÄæÔª ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ