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 6233611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:19:53+00:00 2026-05-24T10:19:53+00:00

119 while(remainLength > 0){ 120 if(remainLength >= MAX_LENGTH){ 121 log(WorkHandler::workLoop, remain %d > max

  • 0
119             while(remainLength > 0){
120                if(remainLength >= MAX_LENGTH){
121                   log("WorkHandler::workLoop, remain %d > max %d \n", remainLength, MAX_LENGTH);
122                   currentSentLength = send(client->getFd(), sBuffer, MAX_LENGTH, MSG_NOSIGNAL);
123                   log("currentSentLength %d \n", currentSentLength);
124                }
125                else{
126                   log("WorkHandler::workLoop, remain %d < max %d \n", remainLength, MAX_LENGTH);
127                   currentSentLength = send(client->getFd(), sBuffer, remainLength, MSG_NOSIGNAL);
128                   log("currentSentLength %d \n", currentSentLength);
129                }
130
131
132                if(currentSentLength == -1){
133                   log("WorkHandler::workLoop, connection has been lost \n");
134                   break;
135                }
136                sBuffer += currentSentLength;
137                log("sBuffer %d\n", sBuffer);
138
139                remainLength -= currentSentLength;
140                log("remainLength %d \n", remainLength);
141
142             }

I have this code and the send function sometimes gets stuck. Some people points out that using non bloking I/O. I am using epoll so I think it is a little bit hard to change the whole design to non blocking mode. Is there any way to prevent blocking the send function?

Thanks in advance..

  • 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-24T10:19:54+00:00Added an answer on May 24, 2026 at 10:19 am

    If you don’t want send to block, you’ll need non-blocking I/O. There’s no way around that.

    You don’t have to put the socket in non-blocking mode though, the MSG_DONTWAIT flag can be used on a per-call basis. But you will need to deal with EAGAIN/EWOULDBLOCK error codes.

    From the man page linked above:

    The flags argument is the bitwise OR of zero or more of the following flags.

    so you can combine that with MSG_NOSIGNAL.

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

Sidebar

Related Questions

I sent a text via GET method to decode html entities ( &#119; =
I'm using Hibernate 3.2.1 and database SQLServer2000 while I'm try to insert some data
Trying to get the width and height of the uploaded image while still in
I'm stuck with this problem. cat ~/.rvm/gems/ruby-1.8.7-p249/gems/nokogiri-1.4.1/ext/nokogiri/mkmf.log Gives this errors (clipped) conftest.c:3: error: 'xmlParseDoc'
While integrating backgroundrb-rails3 I get the following error, ~/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych.rb:148:in `parse': couldn't parse YAML at
So lets say there's a server process that takes way too long. The client
I have xml: <?xml version=1.0 encoding=UTF-8?> <wnio:Dokument xmlns:wnio=http://crd.gov.pl/wzor/2009/03/31/119/ xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance ... > </wnio:Dokument> I want
I am getting following exception while ftp file over to some other machine. org.apache.commons.net.io.CopyStreamException:
getting a no method error while using clearance for authentication, i was trying to
Possible Duplicate: crashing on ios device while navigation using UIModalTransitionStylePartialCurl in xcode 4 HI

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.