|
-
Dec 25th, 2006, 02:18 PM
#1
Thread Starter
Interweb adm/o/distrator
Re: Connect to ip?
You will need to use the method.
-
Dec 25th, 2006, 03:14 PM
#2
Re: Connect to ip?
 Originally Posted by AxeFestis
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.
There are articles & tutorials all over the net explaining how to use the Winsock control.
To send data you'd put:
Code:
Winsock1.SendData "Data here"
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:
If Winsock1.State = sckConnected Then 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.
To connect to yourself you can just use:
Code:
Winsock1.Connect Winsock1.LocalIP, 1234
-
Jul 2nd, 2007, 07:37 AM
#3
Junior Member
Connect to ip?
How do i connect to an ip whit winsock? Or something like that in 2005?
Sorry if this i a n00b question
Last edited by AxeFestis; Jul 6th, 2007 at 03:18 AM.
-
Jul 2nd, 2007, 07:39 AM
#4
Junior Member
Re: Connect to ip?
And can i show on the server if there are any connected?
-
Jul 2nd, 2007, 05:18 PM
#5
Re: Connect to ip?
To connect to an IP (using TCP) use this code:
Code:
Winsock1.Close
Winsock1.Connect "123.123.123.123", 1234
Where "123.123.123.123" is the IP address and 1234 is the port number.
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:
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
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.
-
Jul 3rd, 2007, 04:05 AM
#6
Junior Member
Re: Connect to ip?
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.
-
Jul 3rd, 2007, 08:02 AM
#7
Junior Member
Re: Connect to 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
-
Jul 3rd, 2007, 08:07 AM
#8
Junior Member
Re: Connect to ip?
Could somebody give a hole server client sample whit winsock, Thanks
-
Jul 3rd, 2007, 09:25 AM
#9
Re: Connect to ip?
 Originally Posted by AxeFestis
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.
Sometimes you just have to do SOMETHING yourself.
-
Jul 4th, 2007, 06:00 AM
#10
Junior Member
Re: Connect to ip?
Sorry for ASKING in the forum then
-
Jul 4th, 2007, 02:45 PM
#11
Re: Connect to ip?
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
-
Jul 4th, 2007, 03:43 PM
#12
Re: Connect to ip?
 Originally Posted by AxeFestis
Could somebody give a hole server client sample whit winsock, Thanks
To send files:
http://www.vbforums.com/showthread.php?t=377648
Chat program:
http://www.vbforums.com/showpost.php...2&postcount=43
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|