Solved

CSocket Send() timeout question

Posted on 2009-05-13
2
462 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 31

Assisted Solution

by:Zoppo
Zoppo earned 200 total points
ID: 24375416
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
ID: 24377869
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Exchange Server ActiveSync limit for Contacts 4 95
ShiftLeft challenge 21 76
matchUp  challenge 9 91
Eclipse IDE - Cannot copy/paste from console output 8 123
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
With Windows Embedded Handheld, called Windows Mobile, Microsoft re-designed the user interface. The Start Icon moved down to the bottom, inside the menu bar area.   If you need to hide the Start Icon and/or the SIP (soft input panel, softwar…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

930 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

11 Experts available now in Live!

Get 1:1 Help Now