感谢您使用微软产品。您可以在服务器端分段通过Byte数组分段发送数据,在客户端接受数据时,以vbByte + vbArray方式接受数据就可以了,请参考以下代码:‘服务器端传送数据
Public Sub SendFile(FileName As String, WinS As Winsock)
Dim FreeF As Integer
Dim LocData() As Byte
Dim LenData As Long
Dim sendloop As Long
FreeF = FreeFile
Open FileName For Binary As #FreeF ' Open file
ReDim LocData(1 To 2048) As Byte ' Work in 2kb chunks
LenData = LOF(FreeF) ' Get length of file
For sendloop = 1 To LenData \ 2048 ' Go through file
  Get #FreeF, , LocData 'Get data from the file nCnt is from where to start the get
  WinS.SendData LocData 'Send the chunk
Next
If LenData Mod 2048 <> 0 Then ' If there is any left over at the end
  ReDim LocData(1 To LenData Mod 2048) As Byte ' Clear up the leftovers
  Get #FreeF, , LocData 'Get data from the file nCnt is from where to start the get
  WinS.SendData LocData 'Send the chunk
End If
Close #FreeF ' Close the file
End Sub‘客户端接收数据:
Private Sub WinS_DataArrival(ByVal bytesTotal As Long)
Dim StrData() As Byte
WinS.GetData StrData, vbByte + vbArray
Debug.Print StrData
Put #1, , StrData
End Sub此外在接收数据和发送数据之前,首先需要进行连接的工作。请参考以下文章参考Winsock控件的详细内容:
Winsock Control
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/mswnsk98/html/vbobjWinsockControl.asp微软全球技术中心 VB技术支持
本贴子以“现状”提供且没有任何担保,同时也没有授予任何权利。具体事项可参见使用条款(http://support.microsoft.com/directory/worldwide/zh-cn/community/terms_chs.asp)。