[求助]VB.NET中怎样向一个地址发送数据
我学校好多人用的都是校园网,上网的时候IE会自动转到一个页面,输入学号和密码登录,然后就能上网了。我想用写一个程序,让他们能够开机自动上网,我用sniffer抓包找到了我在登录的时候我给学校服务器发送的字段:
POST / HTTP/1.1
Accept: image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, */*
Referer: http://202.204.48.82/
Accept-Language: zh-cn
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; .NET4.0E)
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip, deflate
Host: 202.204.48.82
Content-Length: 51
Connection: Keep-Alive
Cache-Control: no-cache
Cookie: myusername=40850096; username=40850096; smartdot=1746231
DDDDD=40850096&upass=1746231&0MKKey=123456789&v6ip=
然后我在网上找了好多资料,写了一个下面的代码:
Imports
Imports
Imports System.Text
Imports System.Threading
Public Class Form1
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Try
Dim bytes(1024) As Byte
Dim send = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
Dim localEndPoint As New IPEndPoint(IPAddress.Parse("202.204.48.82"), 80)
send.Connect(localEndPoint)
send.Send(Encoding.Unicode.GetBytes(TextBox1.Text))
send.Close()
MsgBox("Successful")
Catch ex As Exception
MessageBox.Show(ex.ToString())
End Try
End Sub
End Class
想通过这个代码试试能不能发出去,但是发现我把发送过去的字段来回组合也无法成功登录,之后我突然想到会不会是根本没发出去,所以我就用Sniffer监控,果然,我这边根本没有发送出任何数据。
我想知道这个代码哪里有问题,我应该怎么改进?
万分感谢