Sign in to follow this  
Followers 0
Der_Andi

Find the Listening-Socket automatically?

6 posts in this topic

Hi all,

normally, you have to specify the server's ip adress and the port number, if you want to TCPConnect it.

Is there a way, to make the client find this ip adress automatically?

Share this post


Link to post
Share on other sites



If it's a server on your local LAN, you could simply run through the available IP's (your subnet) and attempt to connect to them. If it's not local, I don't know.

It would be easier if the server was broadcasting its address somehow, but you didn't mention whether you were also writing the server part.

;o)

(or


nothing is foolproof to the sufficiently talented fool..

Share this post


Link to post
Share on other sites

If it's a server on your local LAN, you could simply run through the available IP's (your subnet) and attempt to connect to them. If it's not local, I don't know.

It would be easier if the server was broadcasting its address somehow, but you didn't mention whether you were also writing the server part.

Yes, i wrote the server, too, and i already had the idea of broadcasting the IP. But i don't know how to realize that at all.

This script could/would run at my university's LAN. There i get the ip address via DHCP, so it would be very comfortable, if i don't had to inform all the other participants of my current address.

Share this post


Link to post
Share on other sites

It would probably be a lot easier to just setup a proper host name for the server. Then whatever supplies DNS locally could handle all the tricky stuff. That's the way it's done world-wide, aka. "the internet". The clients then simply point themselves at "the-server", or whatever you decide to call it. Check here.

;o)

(or


nothing is foolproof to the sufficiently talented fool..

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Sure, the hostname! Should work with an uncommon hostname.

But i just found a way, how to send and receive the broadcast.

First, run the following script. It runs, until you close it via standard tray icon.

UDPStartup()
$socket = UDPBind(@IPAddress1, 65000)
If @error <> 0 then Exit

While 1
    $data = UDPRecv($socket, 50)
    If $data <> "" Then
        MsgBox(0, "", $data, 1)
    EndIf
    Sleep(1000)
WEnd

Change the IP addresses, if necessary.

Edited by Der_Andi

Share this post


Link to post
Share on other sites

Yup, broadcasts are pretty much always UDP.

But hosts is the way to go methinks. Hosts FTW!

I'm not just blatantly plugging my own pages, they get quite enough hits without any help from me!

;o)

(or


nothing is foolproof to the sufficiently talented fool..

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0