Giannis
Giannis

Reputation: 5526

Getting Foreign Address for TCP

I am trying to run a simple java server on a machine connected to a university network. Although when i check netstat the server only got Local Address and the Foreign Address is 0.0.0.0 . Is this because of a firewall ? How could i get around this ? Thanks .

p.s Im using TCP for the connection.

Upvotes: 0

Views: 1675

Answers (2)

Some programmer dude
Some programmer dude

Reputation: 409356

A listening socket must have a local address for clients to be able to connect to it. The local address is the address of the machine the server program is running on, or "0.0.0.0" if the machine have more than one network address and you want to accept connections on all of them.

When a client connect to your server program you have to accept it, and you get a new socket. This new socket will have both a valid local and remote address. The local address is the address of the network interface where it received the connection, while the remote address is the address of the client connecting to your server program.

I hope this makes things a little clearer.

Upvotes: 3

David Schwartz
David Schwartz

Reputation: 182819

Only connections have foreign addresses. A socket that's just listening for connections has no foreign address.

Upvotes: 4

Related Questions