File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Server request through socket Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Server request through socket" Watch "Server request through socket" New topic
Author

Server request through socket

srinivasan ganesan
Ranch Hand

Joined: Mar 09, 2001
Posts: 54
I have my server running at port 2000. I tried to make a request to the server by telnet like
telnet localhost 2000
but I got an error message saying that a connection could not be extablished to localhost. Could anyone tell me what I'm doing wrong.
Thanks,
Srinivas
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Hi Srinivas,
It should work fine. Are you getting an exception on the server when you try to connect? What OS are you using? You might need to look at the code where your ServerSocket accepts the connection.
I tested with this code and easily connected thru telnet:

If that works, then the problem is in your server.
Hope this helps,
Michael Morris


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
srinivasan ganesan
Ranch Hand

Joined: Mar 09, 2001
Posts: 54
Michael,
Here's the code that I wrote. I tested your code and it works fine but this one doesn't. Do you find anything wrong?

Thanks,
Srinivas
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Hi Srinivas,
You didn't start a thread.
After creating your Server object try this:

That should do the trick.
Hope this helps,
Michael Morris
srinivasan ganesan
Ranch Hand

Joined: Mar 09, 2001
Posts: 54
Thanks Michael...It worked.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Server request through socket