Solved

CSocket Send() timeout question

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

728 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