Unix上的套接字问题,但相同的代码适用于Windows

时间:2014-09-05 16:54:46

标签: java linux windows sockets unix

下面的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;

0 个答案:

没有答案