Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java server works in 32-bit, but not in 64-bit. Why?

I get this strange exception on only when running on 64 bit (windows 7 ultimate) Not when running 32 bit win7 ultimate. Currently its running on java version 1.6.0_26

running server!
java.net.SocketException: select failed
 at java.net.PlainSocketImpl.socketAccept(Native Method)
 at java.net.PlainSocketImpl.accept(Unknown Source)
 at java.net.ServerSocket.implAccept(Unknown Source)
 at java.net.ServerSocket.accept(Unknown Source)
 at Server.main(Server.java:18)

Here is the code:

//import java.net.ServerSocket;
//import java.net.Socket;
import java.io.*;
import java.net.*;




public class Server {


 public static void main(String[] args) {
 System.out.println("running server!");
  int nreq = 1;
  try{
   ServerSocket sock = new ServerSocket(7337);
  for(;;){
   Socket newsock = sock.accept();
   System.out.println("Creating thread...");
   Thread t = new ThreadHandler(newsock, nreq);
   t.start();
   nreq++;
  }
  }

  catch(Exception e)
  {

   e.printStackTrace();

  }
 }
}

The error referenced on line at points to this bit:

Socket newsock = sock.accept();
like image 585
iForgotMyLogin Avatar asked Nov 13 '22 17:11

iForgotMyLogin


1 Answers

You could definitely have an issue with windows 7 and the version of Java SDK you have installed. Download and install the latest version of Java SDK 7 from the oracle website. See if that helps.

like image 53
rekordboy Avatar answered Dec 01 '22 17:12

rekordboy