Solved

CSocket Send() timeout question

Posted on 2009-05-13
2
469 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

If you are anything like me, you install many apps on your phone and have your life on it, sometimes literally.  When I bought my current phone, a Samsung Galaxy S5 from Verizon, they were only selling the versions with 16 GB internal.  I didn't rea…
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 concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

749 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