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

  • SEARCH
  • Home
  • 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 3313666
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:08:30+00:00 2026-05-17T22:08:30+00:00

Hi All I am using a non blocking Socket for sending messages.We were getting

  • 0

Hi All
I am using a non blocking Socket for sending messages.We were getting EGAIN error occassioanally .So I have decided to use Flush(socket) to flush the buffer and make space for new space so that i can avoid EGAIN error .But the problem is Flush(socket) is stuck for indefinite time .

Here is the code

 int res = send(socket, buffer, size+lengthSize,0);


 delete buffer; 

 if ( res== -1 ) 

{

 int error = errno;

 cout("ERROR on SendOnPortString, errno = " << error);

 return 0 ;

 }

 else

 {

  cout<<"Send SucessFul = " << res << "Total Message size"<< size+lengthSize;

  if(res==size+lengthSize)

   flush((ostream&)socket);

  //flush(socket); 


   return 1  ; 

  }

This code printing
Send SucessFul = 11Total Message size 11

But after that its getting stuck in flush(socket) method .Any Idea why its behaving like that

  • 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-17T22:08:31+00:00Added an answer on May 17, 2026 at 10:08 pm

    You cast a socket handle of type int to a reference to a std::ostream in order to avoid compiler warnings/errors when you tried to hand it to flush. I’m surprised it’s not crashing.

    You can’t make more space. The problem isn’t you: the problem is that the system’s internal buffers are full, and they will drain at their own pace in their own time. You can either poll by trying to send over and over till it works (in which case, why are you using non-blocking sockets?), or you use select, poll, kqueue, epoll, libevent, etc. to sleep till the socket is able to accept more data.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a single-threaded non-blocking socket IO server written in Java using nio. When
I'd like to open a pipe using popen() and have non-blocking 'read' access to
I am removing all non-numeric and non-decimal values using: Regex.Replace(A1B2C3.D4E5F6.G7H8I9, @[^-?\d+\.], ); Output: 123.456.789
We have a large number of programmers on different platforms all using CVS. We
Hi all im using a sqlite helper class, but i have a little problem
What is non-blocking concurrency and how is it different than normal concurrency using threads?
Since i discovered the concept of non-blocking scripts i have become obsessed with loading
I'm using non-blocking sockets with winsock and I wonder that if I can partially
coming from node.js point of view, where all code is non-blocking. In Go, non-blocking
I am currently using a non-blocking SocketChannel (Java 1.6) to act as a client

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.