|
-
Oct 17th, 2005, 04:46 AM
#1
Thread Starter
Lively Member
Winsock Control over internet
Hello everybody
i want to connect to web server using winsock control.is this possible.also if my client is connecting through proxy server then how can winsock connect through proxy server.plz help
parth
-
Oct 17th, 2005, 07:03 AM
#2
Re: Winsock Control over internet
Moved to network programming...
-
Oct 19th, 2005, 11:08 AM
#3
New Member
Re: Winsock Control over internet
Dunno about using a proxy server sorry, but without considering proxies, this is how you can download a webpage from your program:
Say on a form you make a text box (Text1), a command button (Command1) and a winsock object (Winsock1). Something like this would download a page when you click the button and display the source into the text box.
VB Code:
Private Sub Command1_Click()
Winsock1.RemoteHost = "www.vbforums.com" 'domain of website
Winsock1.RemotePort = 80 'websites use port 80
Winsock1.LocalPort = 0 'just leave this at 0 (I think it means it auto assigns or something,
'I forget now. A long time since I done this)
Winsock1.Connect 'connect to host
End Sub
Private Sub Winsock1_Connect()
'request the file you want to download from the website including its path.
'you need the two vbCrLf, they are just some kinda thing that the web
'server expects from the client to signal the end of the request.
Winsock1.SendData "GET /game/score.asp HTTP/1.0" & vbCrLf & vbCrLf
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Winsock1.GetData rdata, vbString 'receive the packet and store it into rdata
Text1.Text = Text1.Text & rdata 'append the text that was just received
'onto the end of the content of the text box
End Sub
Hope this helps you make a start. Note that the url used in my example there is invalid, put in your own URL and give it a try. At some stage, you need to close your socket too, but don't do it right after it's received a packet, else it will prevent further packets from coming in (ie. the other chunks of source code as it is being sent bit by bit). The command for this would be Winsock1.Close.
Last edited by Reiko; Oct 19th, 2005 at 11:27 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|