Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sockets: write timeout causes my program to block..

Status
Not open for further replies.

Themuppeteer

Programmer
Apr 4, 2001
449
BE
Hello guys,

I've got the following problem:

I've got 2 self written servers talking to each other,
now sometimes, when the first one "A" asks something to "B", and then "B" answers, I find that "A" is not listening anymore and just continuing his work! Then "B" keeps on waiting while his write doesn't work, and blocks.

Is this normal ? what is the default timeout for a write ?
How do I set the timeout bigger for server "A" so that it would wait longer before it continues...

thnx for any reply.


Greetz,
img


NOSPAM_themuppeteer@hotmail.com (for mails, remove the NOSPAM_)

"Those who say they understand chess, understand nothing"

-- Robert HUBNER
 
It is hard to say without seeing some code.

When you say A is no longer listening, do you mean the socket connection is no longer valid, or is your application not calling read() or recv()?

When B attempts to write(), is -1 being returned? If B is able to write() or send(), and if the socket connection is valid, the data sent by B is sitting in the socket buffer on A, and it just needs to be read in (with read() or recv()).
 
I found the bug! Its been nagging me for months now!
Indeed, its dificult without code, but I think you should know the entire program to be able to answer my question..the solution was in a complete different part of the program, so you were not even able to answer the question...
What happende is that "A" was skipping his duty without reading, because he read the first bytes of his sockets, hoping to find the START delimiter of a message, but there was garbage in my socket , so it did not find the start, and stopped reading. Due to this the other server coulnd't write anymore since it was an open conneciton and the buffer must have been full.
Anywho, its solved now and I'm VERY happy.
Thnx for your time JasonDeckard and sorry about my bad question.


Greetz,
img


NOSPAM_themuppeteer@hotmail.com (for mails, remove the NOSPAM_)

"Those who say they understand chess, understand nothing"

-- Robert HUBNER
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top