This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
Your code works for me when I use a String for the IP. Exactly what are you passing as the IP (Socket takes several different arguments: InetAddress, String (host) String (ip))? Are you certain you were not using ServerSocket? I would expect an "Address already in use" exception if you tried to bind to the same socket a server was using. One further note, it is a good idea to put either Thread.yield or Thread.sleep calls in when writing infinite loops. That way other code can get to use the CPU once in a while.