tcp - Exceptions while doing socket programming in java -


I am new in socket programming in Java while I face these exceptions in running client code. I do not understand how to remove it! Here is my client code

  import java.io. *; Import Java.net *; Public class SOCK_1_CLIENT {public static zero major (string [] args throws exceptions {SOCK_1_CLIENT Client = New SOCK_1_CLIENT (); Client.run (); } Public Zero Run () throws exceptions {socket sook = new socket ("local host", 5050); PrintStream ps = new printstream (sock.getOutputStream ()); Ps.println ("Hello to server from client"); InputStreamReader ir = New InputStreamReader (sock.getInputStream ()); BufferedReader br = new BufferedReader (IR); String msg = br.readLine (); Println (message); }}  

These are exceptions .. !!

  Exceptions to the thread "main" java.net.UnknownHostException: local host at java.net. Javascript on java.net.PlainsSocketImpl.connect (JavaScript) on javascript (unknown source) .net.SocksSocketImpl.connect (unknown source) at java.net.Socket.connect (unknown source) at java.net.Socket.connect (unknown source) at java.net.Socket. & Lt; Init & gt; (Unknown source) on SOCK_1_CLIENT.rain (SOCK_1_CLIENT.java.1) java.net.Socket & Lt; Init & gt; (Unknown source) SOCK_1_CLIENT.run (SOCK_1_CLIENT.java:18)  

Replace the local host with localhost .


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -