Log inUsernamePassword
Log me on automatically each visit    
Register
Register
Log in to check your private messages
Log in to check your private messages
Visual Basic Forum for Visual Basic Programmers VB Forum Index » Communiqué

Post new topic   Reply to topic
Selecting a TCP port
View previous topic :: View next topic  
Author Message
eamonnwalker
Newbie


Joined: 20 Jul 2005
Posts: 4
Location: Baton Rouge, LA

PostPosted: Jul 26th, 2005 01:23 PM    Post subject: Selecting a TCP port Reply with quote

I have a set of applications which communicate with each other through a TCP/IP port via a Winsock control. My problem is getting it to find ports it can use without having to manually set them up beforehand (these applications will be installed on a client's computers).

Is there a way, in VB6, to check to see if a port is available, and/or to create a port if necessary?
What if I just set the port to zero to let it find a port, and then somehow sent the resultant port number to the other application. Would that work?
Back to top
View user's profile Send private message Visit poster's website
ASoufan
Regular


Joined: 15 Aug 2005
Posts: 56
Location: Jordan

PostPosted: Sep 4th, 2005 10:00 AM    Post subject: Reply with quote

hello, I know a simple thing about this which is making a loop from 0 to 65536 and trying to let the socket connect to (i) in the loop, and if the socket status was sckConnected then it means the port is in use and not free, if it didin't connect means the port number (i) is available, example
for i= 1 to 65536
socket.connect localhost, i
if socket.state <> 7 ' <> 7 means not connected
msgbox "The port number " & i & " is available"
next
hope this is a helpfull.

_________________
Ahmed Soufan
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Visual Basic Forum for Visual Basic Programmers VB Forum Index » Communiqué All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Visual Basic Forum runs phpBB | Forum Template © iOptional
VB Resources | SSL | Visual Basic