我正在开发一个客户端服务器程序,我的程序向我显示Socket对象无法通过编译器检测到的一些错误,我已经重新检查它并且没有任何拼写错误或丢失分号但它仍然显示错误.Beside ,我也将我的程序与一些在线套接字编程教程进行比较,我发现我的方法是正确的。我是java socket编程的新手
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将提供完整的计划
答案 0 :(得分:1)
您需要在 currentListView.kendoListView({
dataSource: vm.dataSource,
template: kendo.template(ko.computed(function(){return view()=='full'?firstTemplate:secondTemplate;})),
//code continue
块之外声明socket
:
try