Results 1 to 6 of 6

Thread: I declare war on the Winsock control

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923

    Post

    Who finds the winsock control a pain the in the %?*/&£? I do!

    Ok, this code downloads a TEXT file perfectly from an FTP server, but NOT a binary file (like a GIF which I tried it on). Any ideas...

    (Declarations of form)

    Dim webData As Byte

    Private Sub Winsock1_Connect()

    Dim strSizeCmd As String
    Dim strCommand As String
    Dim strWebPage As String

    strWebPage = "http://www.desktopdriving.co.uk/Graphics/Graphics/Motor_Car.gif"
    strCommand = "GET " + strWebPage + " HTTP/1.0" + vbCrLf
    strCommand = strCommand + "Accept: */*" + vbCrLf
    strCommand = strCommand + "Accept: text/html" + vbCrLf
    strCommand = strCommand + vbCrLf
    Winsock1.SendData strCommand
    End Sub

    Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
    ' I have tried vbString also...
    Winsock1.GetData webData, vbByte

    End Sub

    Private Sub Winsock1_Close()

    Dim intFile As Integer
    intFile = FreeFile()

    Open "C:\Motor_Car.gif" For Binary Access Write As #intFile
    Put #intFile, , webData
    Close #intFile

    End Sub

    As i said, this works fine for text files when you modify the Byte bits (programmer humour! ) to strings, but I need to get binary files like and exe! Any clues guys..thanks.

    Kind regards,

    ------------------
    - Chris
    [email protected]

  2. #2
    Member
    Join Date
    Feb 1999
    Location
    NY
    Posts
    45

    Post

    Well for one i wouldn't use byte, and secondly, there's another control available at http://www.catalyst.com, Personally, i hate both controls and much rather'd use an API, but Winsock direct with VB doesn't work rather well.

    When writing to the file, open it for just Output, it can get messy otherwise.

    ------------------
    -Mystiq

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923

    Post

    Thanks for the link. I will check it out. I managed to fix it anyway - I changed the bytes to strings and did some other jiggery-pokery that I can't remember and would you beleive it did what I actually wanted.

    I know, everyone likes "slimline" API calls, but I'll happily make do with the clunky OCX just so long as it works!

    Kind regards,

    ------------------
    - Chris
    [email protected]

  4. #4
    New Member
    Join Date
    Jul 1999
    Location
    HKSAR
    Posts
    9

    Post

    First, I think the code downloads from a http server ( you wrote "http://www.desktopdriving.co.uk/Graphics/Graphics/Motor_Car.gif " right ?)

    any way, I want to ask which DLL do I use for these winsock API calls and where can I get some information about it?

    thanks

  5. #5
    Guest

    Post

    We pay Microsoft and they give us (a) crappy control(s) to the point that other users recommend getting a different control. Then if you say, "F#@& VB, I'll use C" you get typos in the help and incomplete help at that. On the MSDN cd and the msdn web site. I can't find it now, but there was an example of Win32 and MFC versions and the code obviously wasn't compiled as published. And these guys are supposed to be the professionals. Not to mention the WEBSTER web server sample which works with Netscape but not MS IE...picture that! Or maybe my IE is corrupt--oohh I'm soooo surprised.

    So...how do we wage the war?

    I can only think of using Linux (MS's Win(dows)sock(et) is based off of socket.h) which is more stable anyway (Linux/Unix etc). I'd like a visual editor for X-Windows. Do you know of any?

  6. #6
    New Member
    Join Date
    Dec 1999
    Posts
    2

    Post

    Winsock control is bad, if you use a loop and send data in that loop like an incremental number then when the recieving client (running winsock) cant seperate the data coz its all one mass of data...USE BSD Sockets is the answer...o yeah not on windows heehehe

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