The bind exception on the ServerSocket means that port is in use. You can start your server socket on another unused port and connect your client to that new port number.
To run a server and client on the same machine they'll need to be in separate threads or processes started from the OS. Outside your IDE you can open two command windows and say "java MyServer" in one and "java MyClient" in the other. Even in an IDE like Eclipse you can start the server's main() then the client's main().
Before you do all that, try a completely bogus port number against the server running on the other machine. See if the error message is the same or different.
Have you run through the Sun Networking Tutorial? It steps you through building a little client and server and might answer some questions for you.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Joined: May 20, 2004
here is the thing though. the server is starting at port 3000 on another host, a separate box.. i don't think anythign else is using port 3000...if it is , it shouldn't.
I just did netstat -a | grep 3000, and it is only my server that is on port 3000
Here is the Server portion of the code that is running on the server box
So, what should the client portion of the code be ? shouldn't it be something like this
If you look at the API documentation for Socket, you'll see there are a number of constructors. The no-argument one creates an unconnected socket. If one used this constructor, one would later need to call connect. The constructor you are using is documented as "Creates a stream socket and connects it to the specified port number on the named host", so yes, calling connect() is redundant.