æç°å¨æ个æå头åéæ令åæå°è¿åçæ°æ®å
¨é¨ä¿åå¨ä¸ä¸ªæ°ç»éï¼è¿ä¸ªæ°ç»é¿åº¦æ¯æèªå·±å®ä¹çï¼æä¹å°é¿åº¦è®¾å®å好çäºè¿ååèæ°å |
|
5å |
ä¸è¦ä¼ å
¥Bytes.Length,ä½ åºè¯¥ä¼ å
¥æ°æ®çæ£çé¿åº¦,èä¸æ¯ææ´ä¸ªæ°ç»é¿åº¦é½åè¿å»
|
int count=sendSocket.Receive(RecieveByte);
å¯ä»¥è·åæ¶å°å¤å°åèæ°ç |
|
èä¸ä½ åºè¯¥æåè®®åçæ´å¥½ä¸äº,ä¸è¦ç´æ¥ä¼ å¾çæ件æµ
èµ·å§4个åèåå ¥åç»æ»é¿åº¦ æ¶å°åå¤æä¸ä¸æ¯å¦ç¸ç¬¦ è¿æ ·å¦ææ¶å°çæ°æ®ä¸å®æ´å°±ä¸¢å¼éå好äº,ä¸è¦æä¸å®æ´çæ°æ®ä¹è½¬å¾ç,ä¸å®ä¼åºéç |
|
35å |
第ä¸ä¸ªé®é¢ï¼âæä¹å°é¿åº¦è®¾å®å好çäºè¿ååèæ°åâï¼
è¿ä¸ªè¦ç¨ä¸ä¸ªå¾ªç¯æ¥æ¥ï¼ç´å°æ¥å®ææçæ°æ®ä¸ºæ¢ãå¯ä»¥æ¥ç http://msdn.microsoft.com/en-us/library/6y0e13d3(v=vs.110).aspx pre class=”brush: csharp”>   while (true) { // while循ç¯ï¼ä¸æçæ¥åæ°æ®                     bytes = new byte[1024];                     int bytesRec = handler.Receive(bytes);                     data += Encoding.ASCII.GetString(bytes,0,bytesRec); // è¿ä¸ªå°æ¹ä¸éè¦ãç´æ¥ç¨FileStreamææ¥å°çbyteæ°æ®åå°å¾çæ件就å¯ä»¥ã                     if (data.IndexOf(“<EOF>”) > -1) { // æ¥æ¶å®æ¯ï¼è·³åº                         break;                     }                 } /pre> 第äºä¸ªé®é¢ï¼å¦ä½è½¬æå¾çã æè§å¾ä¸éè¦å¨å åéånew ä¸ä¸ªmemory streamã å¨while循ç¯å¤é¢newä¸ä¸ªFileStream对象ï¼ç¶åå¨while循ç¯å é¨ææ¥å°çbyteæ°ç»åå°æ件éã /div> |
 data += Encoding.ASCII.GetString(bytes,0,bytesRec); // è¿ä¸ªå°æ¹ä¸éè¦ãç´æ¥ç¨FileStreamææ¥å°çbyteæ°æ®åå°å¾çæ件就å¯ä»¥ãè¿ä¸ªæ¿æ¢ç该æä¹åå¢ï¼ææ¢ææµçï¼ä¾ç¶æ示åæ°æ æ |
|
é¦å
å¨while(true) å¤é¢å®ä¹ä¸ä¸ªfilestreamï¼ |
|
è¿æå°±æ¯è·³åºæ¡ä»¶ï¼å 为é£å¥è¯ä¸è¦äºï¼æ以跳åºæ¡ä»¶
 if (data.IndexOf(“<EOF>”) > -1) { // æ¥æ¶å®æ¯ï¼è·³åº                         break;                     } è¦æ¹æï¼ if(bytesRec==0) {    break; } |