I have tried to connect my laptop to another laptop (on the same network, both using Windows 10) using java socket.
Here is the client code :
Socket SocketServIAChat;
try
{
SocketServIAChat = new Socket("192.168.1.10", 50065);
}
catch (IOException ex)
{
jTextAreaErrorMessage.setText(ex.getMessage());
return;
}
And the server code :
try
{
listeningSocket = new ServerSocket(50065);
listeningSocket.setSoTimeout(1500);
}
catch (IOException ex) {
Logger.getLogger(ThreadLoginRequests.class.getName()).log(Level.SEVERE, null, ex);}
...
Socket socketLogin = listeningSocket.accept();
But for some reason, even if I specify an ip address, the laptop only look for a host in loopack, not on the private network. Here is the proof :
I also added a rule to the firewall of both laptop to accept tcp incoming and outgoing on the port 50065.
So is there a way to parameterize the socket to use the right network interface (the one using the private network) or am I missing something here ?
ServerSocketwill accept connections coming from any interface.