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).
如何解决这个问题呢?我在哪里错了? 预先感谢您。