简体   繁体   中英

Connect to Java socket via hostname

Is it possible to connect to Java WebSocket through flash using server hostname, not IP? The reason is the specifications of Cloud9, they don't give any IPs, only hostnames. Tests showed that WebSocket gets requests to connect through browser, but not from Socket class in Flash

programming for a Client:

Socket MyClient;
try {
       MyClient = new Socket("Machine name", PortNumber);
}
catch (IOException e) {
    System.out.println(e);
}

programming for a Server:

ServerSocket MyService;
try {
   MyServerice = new ServerSocket(PortNumber);
    }
    catch (IOException e) {
       System.out.println(e);
    }

for further you can refer below URL :-

http://www.javaworld.com/article/2077322/core-java/core-java-sockets-programming-in-java-a-tutorial.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM