PDA

Click to See Complete Forum and Search --> : I declare war on the Winsock control


chrisjk
Nov 23rd, 1999, 03:47 AM
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
chris.kilhams@btinternet.com

mystiq
Nov 23rd, 1999, 09:45 AM
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

chrisjk
Nov 23rd, 1999, 09:51 AM
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
chris.kilhams@btinternet.com

sydneyfong
Nov 29th, 1999, 09:40 AM
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

Nov 29th, 1999, 11:27 AM
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?

tropas
Dec 3rd, 1999, 06:44 PM
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