我正在开发一个客户端服务器程序和我的程序给我Socket对象上的一些错误不能由编译器检测,我已经重新检查它并没有任何拼错错误或丢失分号,但它仍然告诉我error.Beside,我也与一些在线socket编程教程比较我的计划,我发现我的方式是正确的。我很新到Java Socket编程Java Socket技术方案和符号不能找到DataInputStream类类
try
{
JOptionPane.showMessageDialog(null,"Server : Configuring the port"+port);
ServerSocket server = new ServerSocket(port);
JOptionPane.showMessageDialog(null,"Server : Waiting for client's connection");;
while(true)
{
Socket socket = new Socket();
socket = server.accept();
}
}
catch(IOException e)
{
JOptionPane.showMessageDialog(null,"Server : Nothing Found");
}
try
{
DataInputStream input = new DataInputStream(socket.getInputStream()); // get the input from client
DataOutputStream output = new DataOutputStream(socket.getOutputStream()); // Send the output to client
String word = "Connection Establish";
while(true)
{
word = output.readLine(); // read the message
output.println(word); // display the message to client
}
}
catch(IOException e)
{
JOptionPane.showMessageDialog(null,"Server : Can't Connect To Server, Please Try Again");
}
}
这是我的一些程序的部分,错误显示在DataInputStream类类,因为它不能找到符号插座
http://codepad.org/ISGe9eTx将提供完整的程序
所以,你会得到一个错误。它是什么?发布完整且准确的错误消息。告诉我们它指的是哪一行。不读取错误信息不会帮助您(和我们)解决问题。 –
错误发生在所有DataInputStream类类给我Socket对象未找到 –
错误发生线35/36和40/41线。 SRY不提供明确的指示 –