Solved

CSocket Send() timeout question

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Preface: This article is part of a series focused on cross platform mobile app development (specifically Android and iOS) using the Alloy framework and Titanium Studio made by Appcelerator (https://www.appcelerator.com/). This article presumes a wor…
I recently asked a question (http://www.experts-exchange.com/Programming/Smartphones/Android/Q_28684946.html) about Computer Inventory applications for Mobile Devices.  I was specifically interested in an app I could use on my android phone.  The be…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
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.

829 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