Hi, I have a problem with a server socket (winsock2.h).
I do all standard stuff like listen(), accept() and so on, which all
works fine. I only want one client to be able to connect at a time and
none to be backlogged during this time. So I stop listening, as soon as
one client connects and restart doing it after the client is done.
While a client is connected the server most of the time waits [recv()]
for commands and then deals with them.
Now the actual problem is, that the clients die sometimes (for reasons
which are out of my range) and the server does not always realize this.
It just keeps sitting there waiting for commands, that never come
anymore. And for the reasons mentioned above, no other clients can
newly connect. The only thing I can do in such a situation is to kill
and restart the server.
Is there a standard way for the server to realize, when a client
connected on a socket is dead, so I can make it go back into listen
mode?
Thanks, Holger 8 2044
"Holger Fleckenstein" <ha**********@web.de> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.com... Hi, I have a problem with a server socket (winsock2.h).
I do all standard stuff like listen(), accept() and so on, which all works fine. I only want one client to be able to connect at a time and none to be backlogged during this time. So I stop listening, as soon as one client connects and restart doing it after the client is done. While a client is connected the server most of the time waits [recv()] for commands and then deals with them.
Now the actual problem is, that the clients die sometimes (for reasons which are out of my range) and the server does not always realize this. It just keeps sitting there waiting for commands, that never come anymore. And for the reasons mentioned above, no other clients can newly connect. The only thing I can do in such a situation is to kill and restart the server.
Is there a standard way for the server to realize, when a client connected on a socket is dead, so I can make it go back into listen mode?
Thanks, Holger
Why can't you poll the client every few min or seconds or whatever you wish
and see if it responds?
How else can you know its dead? Its not like it will dead you its fixing to
die..
Jon
"Holger Fleckenstein" <ha**********@web.de> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.com... Hi, I have a problem with a server socket (winsock2.h).
I do all standard stuff like listen(), accept() and so on, which all works fine. I only want one client to be able to connect at a time and none to be backlogged during this time. So I stop listening, as soon as one client connects and restart doing it after the client is done. While a client is connected the server most of the time waits [recv()] for commands and then deals with them.
Now the actual problem is, that the clients die sometimes (for reasons which are out of my range) and the server does not always realize this. It just keeps sitting there waiting for commands, that never come anymore. And for the reasons mentioned above, no other clients can newly connect. The only thing I can do in such a situation is to kill and restart the server.
Is there a standard way for the server to realize, when a client connected on a socket is dead, so I can make it go back into listen mode?
Thanks, Holger
OT, but do a google search for the socket option KEEP_ALIVE.
REH
Well, the thing is, that the client is written in IDL. I don't think
they implemented this option.
The client is not really designed to respond to requests from the
server. It's more or less a one-way street.
"Holger Fleckenstein" <ha**********@web.de> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com... The client is not really designed to respond to requests from the server. It's more or less a one-way street.
ok... simple
have the client "poll" the server.
The server should expect something from the client every x seconds... if it
doens't recieve something then it disconnects.
Hi,
Its important to understand are the clients syncronous (sending
messages regularly evry few time) or asynchronous (sending messages at
irregular intervals)
If they are synchronous , then just make server to listen for some
predestined time and then accept the client conenction as dead..
If they are asynchronous , then the best way is to generate
reconnecttion requests to the client, if the client accepts the
reconnection request , its cool....if not treat them as dead...
Hope this solves your problem....
sandSpiderX
"Holger Fleckenstein" <ha**********@web.de> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com... Well, the thing is, that the client is written in IDL. I don't think they implemented this option.
IDL? You mean CORBA? Go here: comp.object.corba
REH
> IDL? You mean CORBA? Go here: comp.object.corba
No, I mean Interaktive Data Language.
Anyhow, I found a solution:
If you configure the server socket to be non-blocking, recv() will
return SOCKET_ERROR and create an error of WSAEWOULDBLOCK, if the
client has nothing to say. If the client is dead, it will return 0. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Nick Keighley |
last post by:
I'm probably missing something rather obvious, but is there a known
problem with getting a Python based socket program to communicate with
a C based socket program? A simple echo server written in...
|
by: Ben |
last post by:
I've written a fair amount of sockets code using the Winsock2 API, but I am having some trouble converting to the .Net Sockets API, specifically asynchronous sockets.
What I have is a form that is...
|
by: Holger Fleckenstein |
last post by:
Hi
I have written a C++ server and an IDL client, that are supposed to
communicate over sockets. Circumstances require, that only one client
can connect at a time, and possible others are...
|
by: John P |
last post by:
Hi,
I know that some older Unix programs that compile with GCC use socket.h to
connect to and execute other programs. However, I am using Visual C++ 6.0
and it doesn't seem to have socket.h...
|
by: sareel |
last post by:
I need the explanation/code to transmit a complex datastructure like
Linked list or binary tree
using sockets from client to sever...
|
by: JDavis |
last post by:
I am using System.Net.Sockets to connect a client socket to a server that
requires three inputs when I connect: host, port and an identification
number that identifies the person connecting.
...
|
by: ishay44 |
last post by:
I use Winsock2 (WS2_32.DLL) and i want to canceling the 'select()' blocking, in Windows Sockets 1.1 it was possible using the WSACancelBlockingCall(), but it removed for Winsock2 so how can cancel...
|
by: 4.4.bsd |
last post by:
Is there any possible way to use sockets in C, so i can finish a
instant messenger program?
|
by: imaloner |
last post by:
I am posting two threads because I have two different problems, but both have the same background information.
Common Background Information:
I am trying to rebuild code for a working,...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |