« How to Avoid Economic… | Home | EmailMessage trouble »

Using ServerSocket with a system chosen port

05 05 10 - 23:14 Something I learned today: If you offer an service in your application and you announce it on the network using Bonjour, you can pass a port number. But you don't need to ask the user for a port number or hard code one. You can simply let the operation system pick a port for you:

ServerSocket1.Port = 0
ServerSocket1.Listen
MsgBox str(ServerSocket1.Port)

So you specified 0, you started the socket and now you can read what port you got. If you announce this port now on Bonjour using our DNSServiceRegisterMBS class, your clients will easily find you.
No comments

  
Remember personal info?

Emoticons / Textile

Comment moderation is enabled on this site. This means that your comment will not be visible on this site until it has been approved by an editor.



Notify:
Hide email:

Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.