java - Timeout between client & server running on different Internet hosts -


client code

public class dayc {      public static void main(string[] args) throws exception {         bufferedreader d=null;         socket sk=null;         string s="localhost";         int port=5003;         sk=new socket(" remote machine ip ",port);         d=new bufferedreader(new inputstreamreader(sk.getinputstream()));         while(true)         {             string sp=d.readline();             system.out.println(sp);          }      }  } 

server code

public class days {       public static void main(string[] args) throws exception {         int port=5003;         serversocket ss=new serversocket(port);         socket sk=ss.accept();         printwriter my=new printwriter(sk.getoutputstream());         calendar c=calendar.getinstance();         date d=c.gettime();         my.println(d.tostring());         my.flush();         ss.close();     }  } 

the client & server running on different machines.

error

connection timeout

your server code creating socket, accept supposed in loop keep listening , accepting connections., otherwise keep giving connection timeout.

see if helps.


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -