I cannot see anything wrong with the code you have presented. Constructing a Socket object is typically done by the client. A server should construct a ServerSocket object.
I tested the code below, and received the expected exception that the client could not connect. I would suspect that the exception thrown by your code is due to something else (a major clue is that the Socket constructor will not throw a SocketException!). Please create a simple example to test your theories about sockets, and report back here if you still have trouble.
Very simple client code:
Code:
import java.net.Socket;
import java.net.UnknownHostException;
import java.io.IOException;
class Client
{
public static void main(String[] arggs)
{
try {
Socket sock = new Socket("192.168.1.10", 4000);
// ...
}
catch (UnknownHostException e) {
System.err.println(e.toString());
}
catch (IOException e) {
System.err.println(e.toString());
}
}
}