I
I
IsaevDev2015-06-28 21:41:48
Java
IsaevDev, 2015-06-28 21:41:48

How to connect java server to external network interface in Linux?

I start a simple echo server on linux centos:

ServerSocket server = new ServerSocket(portNumber);

or
ServerSocket server = new ServerSocket(portNumber, 10, InetAddress.getLocalHost());


In the console I get, for example:
SERVER :: created Se>rverSocket[addr=vm531350/_serverip_,localport=8080]

In any case, netstat -anp gives:
tcp 0 0 :::8080 :::* LISTEN 27285/java
or
tcp 0 0 ::ffff:_serverip_:8080 :::* LISTEN 27285/java

The server pings normally, everything comes through telnet from another computer, I checked it using tcpdump. But the connection, namely, to the java program does not occur.
That is, this socket is listening locally, do I understand correctly? How to switch to external interface?

hosts file:
_serverip_ vm531350 vm531350 localhost
::1 vm531350 vm531350 ip6-localhost
_serverip_ vm531350
_serverip6_ vm531350


Debate on finding the problem here: https://toster.ru/q/227455

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
pi314, 2015-06-29
@IsaevDev

Instead of:
use:
Looks like getLocalHost() still doesn't resolve correctly (as already discussed in the parallel question).
PS Here is another useful info on the topic.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question