0
TCP 프로토콜을 사용하는 Java로 채팅하고 있습니다. 클라이언트와 서버가 있습니다.Java에서 TCP를 사용하여 채팅
다른 사용자에게 메시지를 보내려면 내 클라이언트를 통해 서버에 메시지를 보내야하며 서버는 다른 클라이언트에게 메시지를 보내야합니다.
서버는 두 온라인 사용자의 주소를 모두 보유합니다. 개인 메시지를 보내면 서버는 ip와 포트를 찾아 소켓을 만듭니다. 문제는 올바르게 작동하지 않는다는 것입니다.
int portNumber = 4444;
String host = "192.168.0.100”;
Socket link;
try {
link = new Socket(host, portNumber);
// Then I set to already created PrintWriter the outputstream
out = new PrintWriter(link.getOutputStream(), true);
} catch (Exception e) {}
// Unfortunately the server freezes here (it doesn't show anything).
어떻게이 문제를 해결하려면 다음
코드인가? 내가 실수 한 걸 어디서 했니? 미리 감사드립니다.