Hie Team.
I am having this problem:
I am developing an application that is connecting to a server, the problem is when the server is not responding, the application wont allow me to do anything so i end up restarting the machine,
i am receiving data using the receive function as follows -
nData = recv( hServer, &wzRec[iPos], nLeft, 0 );
-
please help
thanks in advance
2 2033
I search on google about your problem.
I got one commmon solution it says using select() function before using receive
another solution i got a forum is more interesting -
{ /* this block is just after the return from the socket() call and before connect() */
-
struct timeval tv; /* timeval and timeout stuff added by davekw7x */
-
int timeouts = 0;
-
tv.tv_sec = 3;
-
tv.tv_usec = 0;
-
if (setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof tv))
-
{
-
perror("setsockopt");
-
return -1;
-
}
-
-
if (connect(sockfd, (struct sockaddr *)&their_addr, sizeof their_addr) == -1) {
-
perror("connect");
-
exit(1);
-
}
-
-
while (((numbytes=recv(sockfd, buf, MAXDATASIZE-1, 0)) == -1) && (++timeouts < 1000)) { /* loop to retry in case it timed out; added by davekw7x */
-
perror("recv");
-
printf("After timeout #%d, trying again:\n", timeouts);
-
}
-
printf("numbytes = %d\n", numbytes);
-
-
buf[numbytes] = '\0';
-
-
printf("Received: %s",buf);
-
}
-
if you want to see the entire thread follow the link
hie johny
do yu have any idea on how to use this code for that problem above -
struct timeval tv;
-
-
tv.tv_sec = 3; // 1 Secs Timeout
-
-
setsockopt(hServer, SOL_SOCKET, SO_RCVTIMEO,(char*)&tv,sizeof(struct timeval));
-
I would be very grateful if you would tel me where exactly to put the code like what you told me in your first reply
I am having problems with your first code its not doing any thing at the moment.
THANKS
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Nathan Sokalski |
last post by:
I want to set up SQL Server on Windows XP Pro so that I can use the database
capabilities of ASP and IIS. I am probably using some incorrect settings,
but I am not sure what they are. Here is what...
|
by: banz |
last post by:
Hello
I have a problem to resolve: I wrote a Perlscript which caches data from a
server (local on my machine) I would like to have a other connection to a
remote server but I don't know how to...
|
by: Andreas Håkansson |
last post by:
Hello,
I'm building a small TCP based server which uses the Async commands. When
a new connection is made to the server, I store the new socket in a
hashtable,
using the client IP as the key.
...
|
by: amita |
last post by:
I have a Client (a TcpClient object) established connection with the Server(a TcpListener). I want that when the Server goes down, the TcpClient detects this disconnection and when the Server is back...
|
by: Joner |
last post by:
Hello,
I'm having trouble with a little programme of mine where I connect to
an access database. It seems to connect fine, and disconnect fine, but
then after it won't reconnect, I get the error...
|
by: coosa |
last post by:
Hi,
I was installing SQL Server on my machine and during installation my PC
freezed. It happens frequently on my machine. So i tried after
restarting to install it again and since then i always...
|
by: salvagedog |
last post by:
We use xp_smtp_sendmail for all emailing from SQL Server. Occasionally it fails, generating the following message:
Error: disconnecting from server mail.mydomain.com failed
The failures are...
|
by: =?Utf-8?B?UmludSBHb3BhbGFrcmlzaG5hIFBpbGxhaQ==?= |
last post by:
Hi All,
I have a ASP/C# application that connect to Oracle database . After
issuing my SQL query if I close the browser or move into another page ( ie
whle executing in the databse serevr) will...
|
by: jsacrey |
last post by:
Hello everybody,
I've got a bit of a situation that I could use some guidance with if
possible. I work for an auditing firm where my users audit electronic
shipping data for customers to see if...
|
by: Ontrace |
last post by:
hello,
I have Problem with Client Server Application
when I unplug the client network cable, the server still read the network stream
what function should I use to make server detect that the...
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |