임의의 시스템에서 이식 가능하도록 디자인 된 프로젝트에서 작업 중이며 ServerSocket
을 사용하는 한 컴퓨터에 "서버"유형의 프로그램이 호스팅되고 다른 클라이언트 프로그램이 켜짐 socket
을 사용하여 같은 네트워크에있는 "서버"에 연결된 다른 컴퓨터. 클라이언트가 멀티 캐스트 시스템이나 호스트 시스템을 다른 곳에서 사용하지 않고도 서버가 네트워크에있는 곳을 항상 파악하여 모든 로컬 서버가되도록하고 싶습니다. 나는 특정 IP 주소에 ServerSocket
을 호스트 할 수 있어요 인상이었고, 나는 여기에 시도 :이 할 수있는 방법이면 그러나 오류특정 IP 주소에서 ServerSocket 호스팅
java.net.UnknownHostException: 192.168.859.672
at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:901)
at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1293)
at java.net.InetAddress.getAllByName0(InetAddress.java:1246)
at java.net.InetAddress.getAllByName(InetAddress.java:1162)
at java.net.InetAddress.getAllByName(InetAddress.java:1098)
at java.net.InetAddress.getByName(InetAddress.java:1048)
at com.pulsepanda.dragon.core.Connection.startServer(Connection.java:30)
at com.pulsepanda.dragon.core.Connection.<init>(Connection.java:25)
at com.pulsepanda.dragon.core.Run.main(Run.java:5)
을 반환
try {
InetAddress addr = InetAddress.getByName("192.168.859.672");
serverSocket = new ServerSocket(Integer.parseInt("9532"), 50, addr);
} catch (Exception e) {
e.printStackTrace();
}
특정 IP 주소에서 ServerSocket
호스트를 사용하면 제대로 작동합니까? 내가 뭘 잘못하고 있습니까? 이것이 올바른 일이 아니라면 두 가지 질문이 있습니다 : 멀티 캐스트 시스템없이 로컬에서만이 작업을 수행 할 수있는 방법은 무엇입니까? 2) 내가 실제로 사용하고있는 것은 무엇입니까?
감사합니다.
당신은 시스템 사용자에 구성되어있어 IP 주소에 서버 소켓을 바인딩 할 수 있습니다 계속 달리고있어. – nos
시스템이란 네트워크 또는 호스트 컴퓨터를 의미합니까? – PulsePanda
시스템 = 응용 프로그램이 실행되는 컴퓨터. – nos