下面的java程序在Windows 8上执行时有效,但是当我将程序发布到unix服务器时,它不起作用并在din.read()
方法上抛出超时。
socket2 = new Socket (ip, porta);
socket2.setSoTimeout(3000);
PrintStream pout = new PrintStream ( socket2.getOutputStream() );
DataInputStream din = new DataInputStream( socket2.getInputStream() );
pout.println("GST"); //I am not sure if the other side is receiving this command
pout.flush();
int retint = din.read(); //here is the timeout
System.out.println( retint );
fechaSocket(socket2);
return ""+ retint;