精華區beta Programming 關於我們 聯絡資訊
※ 引述《yippee.bbs@cis.nctu.edu.tw (我要好好活下去...)》之銘言: > 在下用VB5的Winsock control寫了支程式 (Client & Server) > 在兩台電腦間建立TCP連線, 然後傳送資料 > 但是如果傳送的資料大於8KB (不知道是不是每台電腦都是這個數字?) > 所收到的資料就會流失 > ex. > 8192 bytes (8KB) sent -> 8KB received > 8193 bytes sent -> 1 byte received > 8194 bytes sent -> 2 bytes received > : : > : : > 請問一下各位前輩, 為什麼會醬子呢? > 要如何才能解決這個問題呢? Send once 並不一定對應到 recv once, 原因出在 WinSock 提供的 internel send/recv buffer, 而 MS WinSock implementation 的預設值就是 8192 bytes。 所以我想問題出在接收端的程式, 當發送端送出 8193 bytes, 而接收 端的 recv buffer size 為 8192 時, recv() function 一定至少得 分兩次才能收得完, 第一次 n bytes, 第二次 (8193 - n) bytes, here comes your problem ;-) -- ※ Origin: 楓橋驛站<bbs.cs.nthu.edu.tw> ◆ From: kl.cs.nthu.edu.tw