0

I have been tying to create a server on loop-back device using ServerSocket.

ServerSocket server = new ServerSocket(PORT, 0,  InetAddress.getByName(null));

The host to reach the server is provided as ip6-localhost/::1 however it results in error: ERR_INVALID_HTTP_RESPONSE

any pointer on how to access local server using 127.0.0.1?

user755
  • 2,521
  • 3
  • 18
  • 29
  • 1
    Did you try some of the answers and comments in this question? https://stackoverflow.com/questions/2205073/how-to-create-java-socket-that-is-localhost-only ie- trying to pass in localhost or 127.0.0.1 instead? – Howard_Roark Sep 15 '20 at 12:41
  • @Howard_Roark thank you. replacing `null` with `localhost` worked. – user755 Sep 15 '20 at 13:03
  • Ok great -- I'll move my comment to an Answer to "close the loop" or whatever phrase – Howard_Roark Sep 15 '20 at 17:59

1 Answers1

0

Some of the answers and comments in this question address this problem. ie- passing in localhost or 127.0.0.1 instead

    ServerSocket server = new ServerSocket(9090, 0, InetAddress.getByName("localhost"))
Howard_Roark
  • 4,088
  • 1
  • 14
  • 24