本帖最后由 dreamatic 于 2009-09-26 23:16:40 编辑

解决方案 »

  1.   

    不用winsock,用XMLHTTP或者Inet。
      

  2.   

    图片发送完后,加0.05秒的延时t=timer
    while timer-t<0.05
      doevents
    wend
    把它加在图片发送之后
      

  3.   

    inet组包很麻烦哦~~~~xmlhttp测试过,不行,全部搞在一起发送的,我要迎合163服务器的要求,文字归文字,图片数据归图片数据,图片数据是4k一个包的
      

  4.   

    还是csdn好,如果发其他地方,不知何年何月才有结果
      

  5.   

    如果你不负责接收,那就按顺序发送,用抓包软件抓出的内容来证明你发送的数据是正确的即可。
    如果你还要负责接收,因为TCP/IP是基于流而非基于包的传输协议,你就一定要将每次收到的原始数据缓存到一个先进先出队列里面,当监测出队列中已包含一组完整的数据时再触发上层应用程序处理这组数据,同时注意保存原始数据剩下部分,以便将其拼合到后续接收数据之前。
      

  6.   

    分包问题得到解决拉,使用的是猴哥的那个循环
    我自己编写了分包方面的代码,每个包4K
    但是网页不认我的数据包
    返回bad request
    准备按照zhao4zhong1的说法,认真比对原数据和我自己组建的数据
    分就给猴哥和zhao4zhong1拉
    下面是代码:
            ws.RemoteHost = "220.181.31.180"
            ws.RemotePort = 80
            ws.Connect        DoEvents
                 tmr = Timer
            Do Until ws.State = 7
                    DoEvents
                    If Timer - tmr >= 10 Then
                            MsgBox "Connection   Timeout. ", vbOKOnly, "Error "
                            ws.Close
                            Exit Sub
                    End If
            Loop
            'Text2.text = Winsock1.State
            
            strhttpheader = strhttpheader & "POST /dreamatic_altezza/AppInterface/?ApiName=addNewPhoto&username=dreamatic_altezza HTTP/1.1" & vbCrLf
           ' strhttpheader = strhttpheader & "Accept-Language: zh-cn" & vbCrLf
            strhttpheader = strhttpheader & "UA-CPU: x86" & vbCrLf
           ' strhttpheader = strhttpheader & "Accept-Encoding: gzip, deflate" & vbCrLf
            strhttpheader = strhttpheader & "Content-Type: multipart/form-data; boundary=---------------------------7d61194b027e" & vbCrLf
            strhttpheader = strhttpheader & "Cache-Control: no-cache" & vbCrLf
            strhttpheader = strhttpheader & "Content-Length: " & Str(piclen + txtlen) & vbCrLf
            strhttpheader = strhttpheader & "Referer:   blog.163.com" & vbCrLf
            strhttpheader = strhttpheader & "Accept: text/*" & vbCrLf
            strhttpheader = strhttpheader & "User-Agent: UPLOAD~1" & vbCrLf
           ' strhttpheader = strhttpheader & "Connection: Keep-Alive" & vbCrLf
            strhttpheader = strhttpheader & "Host: blog.163.com" & vbCrLf
            strhttpheader = strhttpheader & "Cookie:" & cookie & vbCrLf
            ws.SendData strhttpheader
    DoEvents
      
    ws.SendData at = Timer
    While Timer - t < 0.2
    DoEvents
    Wend
           m = FileLen(Orifilename)
           Dim buffer(4095) As Byte  '4k缓冲
           times = Int(m / 4096)     '循环次数
           temp = (m - 4096 * times) - 1  '最后不足4k部分
            Dim res() As Byte
           ReDim res(temp)
           
           Open Orifilename For Binary As #1
           For i = 1 To times Step 1
                Get #1, , buffer()
                ws.SendData buffer()
                    t = Timer                '延时0.2
                    While Timer - t < 0.2
                    DoEvents
                    Wend
           Next
           Get #1, , res()
                    ws.SendData res()
                    t = Timer
                    While Timer - t < 0.2
                    DoEvents
                    Wend
           Close #1
            
    t = Timer
    While Timer - t < 0.2
    DoEvents
    WendDoEvents
    ws.SendData b
    DoEvents
           
           
           m = FileLen(Smallfilename)       times = Int(m / 4096)
           temp = (m - 4096 * times) - 1       ReDim res(temp)
           
           Open Smallfilename For Binary As #1
           For i = 1 To times Step 1
                Get #1, , buffer()
                ws.SendData buffer()
                    t = Timer
                    While Timer - t < 0.2
                    DoEvents
                    Wend
           Next
           Get #1, , res()
                    ws.SendData res()
                    t = Timer
                    While Timer - t < 0.2
                    DoEvents
                    Wend
           Close #1
           
    t = Timer
    While Timer - t < 0.2
    DoEvents
    Wend
            
    DoEvents
    ws.SendData c
    DoEventst = Timer
    While Timer - t < 0.2
    DoEvents
    Wend
            m = FileLen(Cubefilename)        ReDim res(m - 1)
            Open Cubefilename For Binary As #1
            Get #1, , res()
            ws.SendData res()        Close #1
            t = Timer
    While Timer - t < 0.2
    DoEvents
    WendDoEvents
    ws.SendData d
    DoEventsDoEvents
    ws.SendData e
    DoEvents        strhttpheader = ""
            strhttpheader = strhttpheader & "POST /dreamatic_altezza/AppInterface/?ApiName=uploadEnded&username=dreamatic_altezza HTTP/1.1" & vbCrLf
           ' strhttpheader = strhttpheader & "Accept-Language: zh-cn" & vbCrLf
            strhttpheader = strhttpheader & "UA-CPU: x86" & vbCrLf
           ' strhttpheader = strhttpheader & "Accept-Encoding: gzip, deflate" & vbCrLf
            strhttpheader = strhttpheader & "Content-Type: multipart/form-data; boundary=---------------------------7d61194b027e" & vbCrLf
            strhttpheader = strhttpheader & "Cache-Control: no-cache" & vbCrLf
            strhttpheader = strhttpheader & "Content-Length: " & Str(txtlenf) & vbCrLf
            strhttpheader = strhttpheader & "Referer:   blog.163.com" & vbCrLf
            strhttpheader = strhttpheader & "Accept: text/*" & vbCrLf
            strhttpheader = strhttpheader & "User-Agent: UPLOAD~1" & vbCrLf
            'strhttpheader = strhttpheader & "Connection: Keep-Alive" & vbCrLf
            strhttpheader = strhttpheader & "Host: blog.163.com" & vbCrLf
            strhttpheader = strhttpheader & "Cookie:" & cookie & vbCrLf
            ws.SendData strhttpheader
    DoEvents
    ws.SendData f
      

  7.   

    Cubefilename发送那部分没有修改
    请大家注意,我疏忽了
    修改方法大家可以根据上面2个文件的发送分包方法修改