PDA

Click to See Complete Forum and Search --> : Winsock SendData Problems


SteveCRM
Jul 6th, 2000, 07:46 PM
Winsock1.RemoteIP = "127.0.0.1"
Winsock1.RemotePort = 1000
Winsock1.Connect

Dim MyMessage as String
MyMessage = "Hello, My Name Is Steve"
Winsock1.SendData MyMessage

I get an error on the last line of that code. Why?

SteveCRM
Jul 6th, 2000, 08:30 PM
By the way, ive tried
Winsock1.SendData (MyMessage)
and I still got the error.

noone
Jul 6th, 2000, 09:40 PM
It looks like you are connecting to yourself, do you have a server program runnign to listen on that port? Sorry if I sound insulting.

SteveCRM
Jul 7th, 2000, 08:32 AM
No, that form that that code goes into listens to 1001, the server form sends from 1001 and listens to 1000. I asked about how many ports before. Since 1 - 1024 are reserved for http and ftp, do you think the internet is screwing me up and giving me these problems? Maybe I should make the ports lke 2000, and 2001?

Clunietp
Jul 7th, 2000, 11:02 AM
are you using TCP or UDP?

SteveCRM
Jul 7th, 2000, 11:25 AM
Every winsock control uses TCP

noone
Jul 7th, 2000, 03:30 PM
I may be reading your post wrong but it sounds like you've got the way TCP works a bit mixed up.
When you say:
Winsock1.RemoteIP = "127.0.0.1"
Winsock1.RemotePort = 1000
Winsock1.Connect1

There has to already be a server program listening to port 1000 on your machine, otherwise no connection will be established and thus you cant send any data.

SteveCRM
Jul 7th, 2000, 04:35 PM
Sorry, this is my first winsock program. What is the different between TCP and UDT?

noone
Jul 7th, 2000, 05:59 PM
The main difference between TCP and UDP is that TCP is connection oriented where UDP isnt. TCP is also much more reliable than UDP. But UDP has a much lower overhead for use then TCP.
This link might help you out with using the control:
http://www.vbsquare.com/internet/comms/

SteveCRM
Jul 7th, 2000, 09:08 PM
Thanks noone! That was the perfect tutorial! Just what I needed! :)

arachnid
Jul 8th, 2000, 06:37 PM
I would put the SendData command in the Winsock_Connect event. If you send the data before Winsock connects, you'll get an error.

SteveCRM
Jul 8th, 2000, 07:39 PM
No its connected. The start button (where the senddata is) is dissabled until connected.

FirePoweR
Jul 9th, 2000, 03:26 PM
What error are you getting?

SteveCRM
Jul 9th, 2000, 03:28 PM
Hold on, for some reason its working......thanks