Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Long delay in communication client - server via socket  RSS feed

 
Fernando Skackauskas
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys,

I have a program communication via socket. The program waits for a client message and then responds and wait for another message. bellow the code:





The problem is that: between a message and another, the program takes around two minutes to process. Even the client send a message immediately.

The command stay too long time to processing.

Only after this time (2 minutes) the client gets the message.

What I am doing wrong?

Thanks

Fernando?
 
Henry Wong
author
Sheriff
Posts: 22835
119
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Keep in mind that there are multiple sockets in your server code. There is the rendezvous socket (aka. the ServerSocket). And there are the data sockets that are returned from the rendezvous socket. When your application is processing the data (communicating on the data socket), it is unable to accept any more connections.

I recommend using threads to do the processing / communicating socket, so that your rendezvous socket can go back to handle more connections (ie. go back to call the accept() method).

Henry
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!