我有以下代码:
private Socket mSenderSocket = null;
private DataInputStream in = null;
private DataOutputStream out = null;
...
try
{
mSenderSocket = new Socket(java.net.InetAddress.getByName(TCP_SERVER_IP), 12345);
out = new DataOutputStream(mSenderSocket.getOutputStream());
in = new DataInputStream(mSenderSocket.getInputStream());
}
catch (UnknownHostException ex)
{
System.err.println("Don't know about host.");
}
catch(IOException ex)
{
System.err.println("Couldn't get I/O");
}
我对以下场景感兴趣:
在聊天会话期间,如果发生 I/O 异常,那么我必须执行以下操作:
mSenderSocket = new Socket(java.net.InetAddress.getByName(TCP_SERVER_IP);
现在DataInputStream
和会发生什么DataOutputStream
?
我应该再次初始化这些对象吗?