0
使用TCP我正在用Java聊天它使用TCP協議。 我有一個客戶端和一個服務器端。聊天用Java
要發送消息給其他用戶,我已經通過我的客戶端發送信息到服務器,並且服務器有將它發送給另一個客戶端。
服務器同時擁有在線用戶的地址。當我發送私人消息時,服務器將查找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).
如何解決這個問題呢?我在哪裏錯了? 預先感謝您。