 |
| View previous topic :: View next topic |
| Author |
Message |
eamonnwalker Newbie
Joined: 20 Jul 2005 Posts: 4 Location: Baton Rouge, LA
|
Posted: Jul 26th, 2005 01:23 PM Post subject: Selecting a TCP port |
|
|
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 |
|
ASoufan Regular

Joined: 15 Aug 2005 Posts: 56 Location: Jordan
|
Posted: Sep 4th, 2005 10:00 AM Post subject: |
|
|
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 |
|
|
|
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
|
|