Hi,
I have a Java application which runs a server socket on a PC. Various
sensors (using microprocessors ) can call it up and each gets its own thread
running the socket connection.
The sensors send in data at random times. This all works OK.
Sometimes one of the sensors fails or goes off-line. How can I tell from
the server end? If they fail I would like to close the link down.
Obviously I could poll links on a periodic basis and mark the link as dead
after a specified timeout but this seems rather inelegant. If I chose a
short period the network might be very busy for a short time and cause a
false timeout. If the period is long then I either have to start a new
thread to handle the polling or elselive with my main application blocking.
Anyway, there might be several hundred sensors and I don't want to clutter
the network up with polling packets. Is there a better way?
I would be grateful for any help.
Regards,
Nick 2 4260
Nick Toop wrote:
Hi,
I have a Java application which runs a server socket on a PC. Various
sensors (using microprocessors ) can call it up and each gets its own thread
running the socket connection.
The sensors send in data at random times. This all works OK.
Sometimes one of the sensors fails or goes off-line. How can I tell from
the server end? If they fail I would like to close the link down.
Obviously I could poll links on a periodic basis and mark the link as dead
after a specified timeout but this seems rather inelegant. If I chose a
short period the network might be very busy for a short time and cause a
false timeout. If the period is long then I either have to start a new
thread to handle the polling or elselive with my main application blocking.
Anyway, there might be several hundred sensors and I don't want to clutter
the network up with polling packets. Is there a better way?
I would be grateful for any help.
Regards,
Nick
If you don't send data on a TCP stream, nothing is sent. There is no
detection of crashes built into the TCP protocol, so you will have to
implement this yourself.
On the client side I usually mark the time of the last packet sent and
use that for determining when a keepalive packet needs to be sent
meaning that if the application itself sends and receives data regularly
no keepalive packets needs to be sent at all. Only when the stream is
idle will I send keepalives.
On the server side I mark the time of the last received packet from each
client and have a timer to check the clients. If the server hasn't heard
from the clients in a configurable amount of time the stream is shut down.
On Wed, 27 Aug 2008 13:01:42 +0200, Robert Larsen wrote:
Nick Toop wrote:
>Hi,
I have a Java application which runs a server socket on a PC. Various sensors (using microprocessors ) can call it up and each gets its own thread running the socket connection.
The sensors send in data at random times. This all works OK.
Sometimes one of the sensors fails or goes off-line. How can I tell from the server end? If they fail I would like to close the link down.
Obviously I could poll links on a periodic basis and mark the link as dead after a specified timeout but this seems rather inelegant. If I chose a short period the network might be very busy for a short time and cause a false timeout. If the period is long then I either have to start a new thread to handle the polling or elselive with my main application blocking. Anyway, there might be several hundred sensors and I don't want to clutter the network up with polling packets. Is there a better way?
I would be grateful for any help.
Regards,
Nick
If you don't send data on a TCP stream, nothing is sent. There is no
detection of crashes built into the TCP protocol, so you will have to
implement this yourself.
http://www.developerweb.net/forum/showthread.php?t=2983 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Joe |
last post by:
Hi,
I browsed the news and a few seem to have this problem too, but no
solution !
I have a client server application where in case the connection gets bad
(crashes or whatever) client or server (who knows it first) closes the
socket and than wants to establish the SAME connection again ( due to
firewall reasons it has to be the SAME IP AND PORT).
|
by: Frank Meng |
last post by:
Hi.
I am trying a csharp sample from
http://www.codeproject.com/csharp/socketsincs.asp .
(Sorry I didn't post all the source codes here, please get the codes
from above link if you want to try).
I had some troubles when I started 6 threads (each thread made a
separate connection) and sent messages to same server simultaneously.
Sometimes, not always, the socket looks like ok, but really it is
dead.
I don't why it happens.
|
by: |
last post by:
Hi all,
I have a simple .aspx page running on net 2.0 that is trying to do a http
post to a remote server. Here is the code
Private Function ProcessRequests(ByVal strbody As String) As String
Dim returnstr As String
Dim URL As String = "http://www.dydomain.com/test.asp"
|
by: Nuno Magalhaes |
last post by:
I've got a simple problem I guess. How do I know when a connection is
terminated without losing any data?
I do something like the code below, but sometimes between
socket.Receive and socket.Send I get the last chunk of data and am not
able to retrieve it anymore cause the socket will be dead.
Loop:
{
socket.Receive
<----------- data arrives
|
by: Droopy |
last post by:
Hi,
I wrote a program that runs on about 20 machines.
Each machine is connected with a socket on all other machines.
Each socket has its own handling thread.
The main reading loop is using Poll () with a 100ms timeout and Receive ()
to check incoming data.
Send () is used to send data.
There are exchanging many small messages (most are less than 250 bytes).
It runs well for a few hours than I got socket exceptions, mainly "An
| |
by: Abubakar |
last post by:
Hi,
lets say I have a connected SOCKET s. At some point in time, I want to know
if the "s" is still valid, that it is still connected. Is there any API that
I can give me this information?
And can I register some callback like thing, that would inform me when "s"
disconnection happens? What I usually do is while I call "send" or "recv", I
get the socket_error and through that I know whats the status. But in this
situation actually I...
|
by: phplasma |
last post by:
Hey,
I am currently attempting to implement a multi-threaded C# socket,
using SSL (.pem file/certification/private key combo) server using
Visual Studio C# Express.
I have successfully made the client application establish a connection,
and send data, which appears in plain, de-crypted text on the server -
this works.
|
by: atlaste |
last post by:
Hi,
In an attempt to create a full-blown webcrawler I've found myself
writing a wrapper around the Socket class in an attempt to make it
completely async, supporting timeouts and some scheduling mechanisms.
I use a non-blocking approach for this, using the call to 'poll' to
support the async mechanism - rather than the 'begin' and 'end'
functions. I already found that connecting doesn't set the
"isconnected" variable correctly...
|
by: jm.carp |
last post by:
I'm writing a tcp client that grabs data from a server at 32hz. But
the connection drops exactly one minute after it's opened. I can get
data from the server fine for the first 60s, and then the connection
goes dead. What's going on?
|
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: 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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |