Здравствуйте!
Помогите пожалуйста разобраться с сокетами:
Dim sock As New Net.Sockets.Socket(Net.Sockets.AddressFamily.InterNetwork, Net.Sockets.SocketType.Stream, Net.Sockets.ProtocolType.Tcp)
Dim pcom As String
pcom = "email=" & GetWebMail(log) & "&pass=" & pass & "&expire=&vk="
sock.Connect("login.vk.com", 80)
If sock.Connected Then
Dim head As String = "POST http://login.vk.com/?act=login HTTP/1.1" + vbNewLine
head += "Host: login.vk.com" + vbNewLine
head += "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10 WebMoney Advisor" + vbNewLine
head += "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5" + vbNewLine
head += "Accept-Language: ru-ru,ru;q=0.8,en-us;q=0.5,en;q=0.3" + vbNewLine
head += "Accept-Charset: windows-1251,utf-8;q=0.7,*;q=0.7" + vbNewLine
head += "Keep-Alive: 300" + vbNewLine
head += "Connection: keep-alive" + vbNewLine
head += "Referer: http://vkontakte.ru/index.php" + vbNewLine
head += "Cookie: remixlang=0; remixchk=5; remixsid=nonenone" + vbNewLine
head += "Content-type: application/x-www-form-urlencoded" + vbNewLine
head += "Content-Length: " & pcom.Length & vbNewLine
head += "" & vbNewLine
head += pcom
sock.Send(System.Text.Encoding.ASCII.GetBytes(head))
Dim recvBuffers As New List(Of ArraySegment(Of Byte))(2)
Dim bigBuffer As Byte() = New Byte(1024) {}
recvBuffers.Add(New ArraySegment(Of Byte)(bigBuffer, 4, 2))
recvBuffers.Add(New ArraySegment(Of Byte)(bigBuffer, 20, 500))
Dim bytesReceived As Integer = sock.Receive(recvBuffers)
Console.WriteLine(System.Text.Encoding.ASCII.GetString(bigBuffer))
Console.ReadKey()
Else
Console.WriteLine("Ошибка подключения к vkontakte.ru")
End If
Почему приходят не все данные, а только обрывок?
Заранее благодарен.
Ответить
|