You will need to use themethod.vb Code:
Winsock1.SendData
Printable View
You will need to use themethod.vb Code:
Winsock1.SendData
There are articles & tutorials all over the net explaining how to use the Winsock control.Quote:
Originally Posted by AxeFestis
To send data you'd put:
Make sure the Winsock is connected or you will get an "invalid state" error. You could even do a simple check with an If statement:Code:Winsock1.SendData "Data here"
If 127.0.0.1 is showing up as your local IP then that means you either put "127.0.0.1" or "localhost" as the RemoteHost in the Connect statement.Code:If Winsock1.State = sckConnected Then Winsock1.SendData "Data here"
To connect to yourself you can just use:
Code:Winsock1.Connect Winsock1.LocalIP, 1234
How do i connect to an ip whit winsock? Or something like that in 2005?
Sorry if this i a n00b question :sick:
And can i show on the server if there are any connected?
To connect to an IP (using TCP) use this code:
Where "123.123.123.123" is the IP address and 1234 is the port number.Code:Winsock1.Close
Winsock1.Connect "123.123.123.123", 1234
That will be in your client project.
On the server project, you'd have a Winsock control and the code would be something like this:
That's just for accepting one connection at a time. For multiple connections, you'd have to use a control array of Winsocks on the server side.Code:Private Sub Form_Load()
Winsock1.Close
Winsock1.LocalPort = 1234
Winsock1.Listen
End Sub
Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
Winsock1.Close
Winsock1.Accept requestID
Me.Caption = "Connected [" & Winsock1.RemoteHostIP & "]"
End Sub
Tanks It work but now i want to send data over the connection please give me an example. I have read some but i dident mange them to work. And when i connect it just says 127.0.0.1 and that aren't my local ip.
OK, and how do you receive the data i tired get data but when i try to transfer it to a label or something it wont work could you give an example
Could somebody give a hole server client sample whit winsock, Thanks
No. There are plenty of tutorials and example code on the net that you can learn from.Quote:
Originally Posted by AxeFestis
Sometimes you just have to do SOMETHING yourself.
Sorry for ASKING in the forum then
I wasn't trying to sound rude, it's just there's so many people here expecting all the code to be given to them. I don't think that's what you were wanting.
I can write a very basic client/server example if you like but really, there are so many examples on the internet.
Take a look at these:
http://www.pscode.com/vb/scripts/Bro...t=Alphabetical
To send files:Quote:
Originally Posted by AxeFestis
http://www.vbforums.com/showthread.php?t=377648
Chat program:
http://www.vbforums.com/showpost.php...2&postcount=43