Jump to content

Solved (I'm an idiot): How to get the local IP of current computer


Recommended Posts

I am writing a set of a few programs that will be run on separate computers on the same network and communicate via TCP.

I have a server that does all of the receiving, and 2 controllers that send messages. For the controllers, the user enters the IP of the server at startup, which is fine because the Server IP may be different each time, but I do not want to have to do that for the server. I would like to automatically determine the local IP and use that as the IP it listens on.

Is there any way to do this? I am not sure where to start...

Edited by JFee

Regards,Josh

Link to comment
Share on other sites

Macro

@IPAddress1 ;IP address of first network adapter.

@IPAddress2 ;IP address of second network adapter. Returns 0.0.0.0 if not applicable.

I am writing a set of a few programs that will be run on separate computers on the same network and communicate via TCP.

I have a server that does all of the receiving, and 2 controllers that send messages. For the controllers, the user enters the IP of the server at startup, which is fine because the Server IP may be different each time, but I do not want to have to do that for the server. I would like to automatically determine the local IP and use that as the IP it listens on.

Is there any way to do this? I am not sure where to start...

Link to comment
Share on other sites

Hmm... but how do I know which is the current computer? This would be good if I was connecting to the same computer every time, but I can't find out the current one by this.

Regards,Josh

Link to comment
Share on other sites

Hmm... but how do I know which is the current computer? This would be good if I was connecting to the same computer every time, but I can't find out the current one by this.

What are you talking about? @IPAddress1 always returns the IP of the computer the script is running from.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...