Solved

CSocket Send() timeout question

Posted on 2009-05-13
2
461 Views
Last Modified: 2013-12-27
I am using CSocket in my Windows Mobile program like so:
CSocket *sock;

I send data to a server running on a PC like so:
sock->Send(&cData, nLength);

I have noticed that if the server is down the socket does not time out.

How can I get it to time out after say a few seconds then try again?
0
Comment
Question by:Wanting2LearnMan
2 Comments
 
LVL 30

Assisted Solution

by:Zoppo
Zoppo earned 200 total points
Comment Utility
Hi Wanting2LearnMan,

here's another EE thread where this issue was discussed with an accepted answer: http://www.experts-exchange.com/Programming/System/Windows__Programming/MFC/Q_11553958.html

I hope that helps,

ZOPPO
0
 
LVL 39

Accepted Solution

by:
itsmeandnobodyelse earned 300 total points
Comment Utility
You might try to derive from CSocket and and overwrite the OnClose handler function. That function should/might be called if the socket closed in the meantime.

I personally prefer the native socket calls which are more transparent (IMO). As far as I experienced a send call would fail immediately if the server disconnected or was down. But it may depend on the kind of connection and operation system configuration whether the client's TCP/IP subsystem was able to find out that a server was down. If your's is not, you should call select with timeout before any read or write and decide to break if a select for write timeouts.  
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

A short article about problems I had with the new location API and permissions in Marshmallow
You should read OS supplied guidelines before developing. I can't stress that enough. The guidelines will help you understand the reasons mobile app developers do what they do.  Apple is very particular when they review appstore submissions.
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now