Results 1 to 4 of 4

Thread: Samples Of Winsock

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800

    Question

    I have not gotten winsock to work! Can someone send me an example of a small program that has some comments?

  2. #2
    Lively Member
    Join Date
    Nov 1999
    Location
    Melbourne, Victoria, Australia
    Posts
    126

    Lightbulb

    A sameple winsock application. Connets to a webserver and downloads a .html file...

    Create a new form...
    Add a text box caled "Text1"
    Add a command button called "Command1"
    Add a winsock control called "Winsock1"

    Set Text1 to MultiLine = True and ScrollBars = Both

    Paste the following code and run....


    Private Sub Command1_Clik()
    'connect to server on port 80
    Winsock1.connect "www.vb-world.net", 80
    End Sub

    Private Sub Winsock1_Connect()
    'send http request (ask for the file)
    Winsock1.senddata "GET /index.html HTTP/1.0" & vbclrf & vbcrlf
    'you must send two vbcrlf's when using HTTP
    End Sub

    Private Sub Winsock1_DataArrival(bytes as long)
    'weve recieved a packet, keep track of it and add it to the text box
    Winsock1.getdata TempStr, vbString
    text1.text = text1.text & TempStr
    End Sub

    Private Sub Winsock1_Close()
    'its complete, the httpd server automatically closes the connection
    'when the file get is complete
    msgbox "Download complete."
    End Sub
    Regards,

    Paul Rivoli
    ---------------------
    [email protected]
    http://members.dingoblue.net.au/~privoli

  3. #3
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Nitro
    Posts
    633
    Paul!

    Is this the method to download a zip file?
    Chemically Formulated As:
    Dr. Nitro

  4. #4
    Lively Member
    Join Date
    Nov 1999
    Location
    Melbourne, Victoria, Australia
    Posts
    126

    Thumbs up

    You can use that code for any file you want...However for a binary file such as a .zip or .exe you will need to store all the bytes into an array then dump the bytes into a file....

    Putting the bytes into a textbox for a binary file (.zip or .exe etc..) will not work, you will need to put it in a byte array instead....

    Search around the place for some code that stores a string into a byte arrray and dumps it to a file...

    I'll try working on a file download agent later tonight...

    Cheers
    Regards,

    Paul Rivoli
    ---------------------
    [email protected]
    http://members.dingoblue.net.au/~privoli

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width