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 2064
"Holger Fleckenstein" <ha**********@w eb.de> wrote in message
news:11******** *************@g 43g2000cwa.goog legroups.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**********@w eb.de> wrote in message
news:11******** *************@g 43g2000cwa.goog legroups.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**********@w eb.de> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.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**********@w eb.de> wrote in message
news:11******** **************@ g14g2000cwa.goo glegroups.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.cor ba
REH
> IDL? You mean CORBA? Go here: comp.object.cor ba
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 Python
(the example from Python in a Nutshell actually) will happily talk
to a Python based client. If a C based client is substitued the connection
is refused (or so the C client reports). The C client will talk to
a C server.
--
|
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 both a client and a server. When the form starts I create a listening socket and call Socket.BeginAccept(). When a client connects my accept function is called, and it is on a separate thread. After I accept the client connection I connect to...
|
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 refused.
So the first thing I did, was to set a short connection timeout on the
client (IDL) side:
socket, lun, port, connect_timeout=1
|
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 included. Is there any standard
cross-platform way (ie can compile in both Visual C++ 6 and GCC) to execute
and connect to other programs?
Thanks,
John P
|
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.
None of the overloads for either the Connect or BeginConnect methods takes
that many inputs (basically they take host and port only).
Would it be best to create a new class that derives from the base class
System.Net.Sockets and implement a new...
|
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 this blocking now?
|
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, commercially sold application with only partial build instructions. The previous maintainer of the code (a
mixture of C and C++) is no longer with the company, but when he built the code he used MSVC++, and though I am not certain of the version he was ...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |