This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Server request through socket

 
srinivasan ganesan
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
srinivasan ganesan
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Michael...It worked.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic