我用java写的程序,在windows下运行良好,可是将Server程序放在linux下,client使用windows的时候就无法链接到Server端。请问各位打下这个是什么原因?和端口有关系吗?
附上Server代码,希望能得到解决方法:import java.io.DataInputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
public class WindowDao extends Thread {static int port = 4320;Socket client;public static boolean windowServer = false;public WindowDao() {}public WindowDao(Socket c) {
this.client = c;
}public void run() {
System.out.println(login ok!);
PrintWriter out = null;
try {
// Mutil User but cant parallel
while (true) {
// ******************************************************
DataInputStream dis = new DataInputStream(client.getInputStream());
out = new PrintWriter(client.getOutputStream(), true);String username = dis.readUTF();
System.out.println(username);
}
} catch (IOException ex) {
ex.printStackTrace();
} finally {
if (out != null) {
out.flush();
out.close();
}
try {
client.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}public static void main(String[] args) throws IOException {
ServerSocket server = new ServerSocket(port);
new WindowDao(server.accept()).start();
}
}
附上Server代码,希望能得到解决方法:import java.io.DataInputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
public class WindowDao extends Thread {static int port = 4320;Socket client;public static boolean windowServer = false;public WindowDao() {}public WindowDao(Socket c) {
this.client = c;
}public void run() {
System.out.println(login ok!);
PrintWriter out = null;
try {
// Mutil User but cant parallel
while (true) {
// ******************************************************
DataInputStream dis = new DataInputStream(client.getInputStream());
out = new PrintWriter(client.getOutputStream(), true);String username = dis.readUTF();
System.out.println(username);
}
} catch (IOException ex) {
ex.printStackTrace();
} finally {
if (out != null) {
out.flush();
out.close();
}
try {
client.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}public static void main(String[] args) throws IOException {
ServerSocket server = new ServerSocket(port);
new WindowDao(server.accept()).start();
}
}
我下载了一个.bin的文件,可是在图形界面双击它,却无法打开,提示:无法打开文件/root/Desktop/XXX.bin
gedit无法检测字符编码。
请检查您是否正在尝试打开一个二进制文件。
从菜单中选择一种字符编码,然后再试。字符编码:UTF-8
请问类似这样的文件应该如何安装?有什么命令吗?他是压缩文件吗?我点击重试也不行,望高手指导!!!
我也不是很清楚
第二个问题,直接./xxx.bin这样不行吗?