What name do i use to connect to a server socket in java -


i writing telnet program in java using server socket , socket classes. current code client program. user types in server name , port connect on.

static socket getsocket() {     while(true)     {         system.out.println("what server want connect on port?");         string info = sc.nextline();         string host = info.split(" ")[0];         int port = integer.parseint(info.split(" ")[1]);          try          {             inetaddress ip = inetaddress.getbyname(host);             return new socket(ip, port);         }          catch (unknownhostexception e)          {             system.err.println("the host unknown.");         }         catch (ioexception e)          {             system.err.println("network error.");         }     } } 

i tried connecting on localhost, , worked. tried connecting friend on remote computer using ip address network name , did not work giving exception. name use connect remote server.

you need give friend your remote ip address.


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -