Data 不要用 string类型,用byte数组

解决方案 »

  1.   

    用byte不行,我试过了,我怀疑是在写如文件时定位有问题,导致每一块数据都少了一部分,但我不知错在那里,是seek吗?
      

  2.   

    怎么会不行,二进制数据你用String 类型接受,当收到ASCII不能显示的
    数据时,你又怎么记录,写入文件中呢?
    你这个程序只能收文本文件。试试去,收文本应该是对的。
      

  3.   

    用这个吧:
    Internet Transfer
      

  4.   

    看看这个老外写的程序
    http://www.a1vbcode.com/coderedirect.asp?type=application&ID=327
      

  5.   

    通常总是将 GetData 方法与 DataArrival 事件并用,而 DataArrival 事件包含 totalBytes 参数。如果指定一个比 totalBytes 参数小的 maxlen,则将得到警告 10040,以此指出剩余的字节将丢失。1、每次发送完毕,等待一段时间,等对方接收处理数据
    2、全部发送完毕,等待一段时间,然后再发送TransferEnd标志
    3、你的问题在于等待的时间不够长,等待的程序如下:Sub Pause(HowLong As Long)
    Dim u%, tick As Long
    tick = GetTickCount()Do
    u% = DoEvents
    Loop Until tick + HowLong < GetTickCount
    End Sub发送程序:
    Function SendData(sData As String, tcpSock As Winsock) As BooleanOn Error GoTo ErrHDim TimeOut As Long' 连接上才能发数据
    If tcpSock.State <> sckConnected Then
    MsgBox "连接错误:" & GetTcpState(tcpSock.State), vbCritical, "错误"
    Exit Function
    End IftcpSock.SendData sData' check for timeout or closed socket
    Do Until (tcpSock.State = 0) Or (TimeOut < 100000)
    DoEvents
    TimeOut = TimeOut + 1
    If TimeOut > 100000 Then Exit Do
    Loop' ok.... sent
    SendData = True
    Exit FunctionErrH:
    SendData = False
    MsgBox "发送数据出错:" & Err.Description, 16, "错误"End Function
      

  6.   

    服务端每次发多大?winsock的buffer只有4K