Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6891803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:27:22+00:00 2026-05-27T06:27:22+00:00

I have a network application where it is possible that the server is not

  • 0

I have a network application where it is possible that the server is not reachable. The client sends on idle time every 30 seconds the string ping\n to the server over a TCP connection so that the server can see if the client is online or not. My server doesn’t response at all. If the connection is interrupted and the client goes on to send the “ping” messages the packages will be stored, maybe by the operating system, in a buffer until the server got the packages. If the Server is back online it is possible that the server gets dozens of ping packages at once. Is it possible to get the count of bytes a that buffer?

Edit:
How can I get the count bytes which have to be send out by the client?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:27:22+00:00Added an answer on May 27, 2026 at 6:27 am

    If you are asking whether or not it is possible to detect, before you call read on a network socket, how many bytes are available to be read, the short answer is no. You can only detect whether or not there are any bytes available to be read but not the number of bytes. The client may also have bytes written to its kernel but blocked by the server’s full buffers so the server itself may not know how many bytes are ready to be read. Also, from the client side, there is no way to find out how much data has been written by the client but not consumed by the server.

    The data is buffered both on the client side and the server side but there is no way in Java to be able to see how many bytes are in those buffers. You might be able to get it with some very specific kernel calls in C but it would be very non portable.

    • One thing to consider is to use Socket.setKeepAlive(true) which will use the TCP mechanisms to keep the socket alive. I’m not sure how reliable that is from the server side but it should then get a -1 from the read when the socket times out after the client goes away.
    • Another is to make a separate TCP connection for each ping. If that is too expensive then you can reconnect after a certain number of ping tries.
    • A third thing to consider is to send UDP packets from the client which won’t be buffered and are a lot less expensive. You should send more often since there is no retry as well.
    • The server could also send back some sort of response so the client knows that the client knows the socket is still good. It can reconnect if it doesn’t get the response.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a C application that sends data to a UDP server every few
I have a server application that receives information over a network and processes it.
I have an server-application Foo that listens at a specific port and a client-application
We have an application (a custom network management tool for building automation) that supports
I have an application which runs a tool that requires network connection. Now my
I have an ASP.net Application that runs on the internal network (well, actually it's
I have a legacy C++-based application that timestamps incoming network traffic using the CRT
If you have a web application that will run inside a network, it makes
I am looking to create a client/server application that I can use to slit
Is it possible to change what each key does? I have a client application

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.