473,796 Members | 2,661 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

send() on non-blocking sockets

4 New Member
Hi there. I'm developing a tool, which uses non-blocking sockets on Linux.

When I'm sending something to socket with send(), the return value is -1, which means error. But it's not an error. <errno> indicates that this is EWOULDBLOCK, which means that my request will be async ;-)

I want to get number of bytes really written to socket, but not -1 as I get now.

Expand|Select|Wrap|Line Numbers
  1. switch (errno)
  2.   {
  3.     case EWOULDBLOCK:
  4.        while (1)
  5.          {
  6.             tv.tv_sec = timeout; /* my timeout */
  7.             tv.tv_usec = 0; 
  8.  
  9.             /* here - wait for socket is ready to write*/
  10.             FD_ZERO (&writefds); 
  11.             FD_SET (priv->socket, &writefds); 
  12.             rc = select (priv->socket+1, NULL, &writefds, NULL, &tv); 
  13.  
  14.              if (rc < 0)
  15.                 {
  16.                   /* error on select() */
  17.                   return 1;
  18.                 }
  19.               else if (rc==0)
  20.                   {
  21.                      /* time out */
  22.                      continue;
  23.                   }
  24.                else if (rc > 0)
  25.                   {
  26.                      /* data was sended */
  27.                      /* HERE I want to get number of bytes really written */
  28.                      break;
  29.                   }
  30.              }
  31.  
  32.           break;
  33.  
Jan 9 '09 #1
1 3721
AlannY
4 New Member
All right, I solved this problem.

Thanks to everyone ;-)
Jan 9 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
4483
by: Wayno | last post by:
Hoping someone can help me out with this problem. First problem, is I am unable to view my php error log. In my php.ini I have my log in /var/www/logs/php_error_log. However, it has remained empty. Secondly, my sendmail works fine from command prompt. However, when trying to send mail through a php script (I have tried a couple), it says it is succesfull, but my mail logs show nothing going out. No error messages. Can someone take a look...
11
12094
by: Google Mike | last post by:
I've got RH9 Linux with default PHP. Is there a way to send email on Linux to an Exchange Server from PHP and/or other tools when there is *NOT* SMTP access? Has anyone figured out a way to use PHP to get inside an OWA (Microsoft Outlook Web Access) website to send email that way? The reason I ask is because my corporate office is going to do away with our rogue SMTP server access and force everything through Exchange
1
2293
by: Bruce W.1 | last post by:
I'm new to ASP (but not ASP.NET) and I'm trying to setup a simple ASP web form to send an email to me. So I try this code: http://www.library.unr.edu/subjects/guides/mailplay.asp I upload the web page file to my hosting company, which is running Windows 2000, and I get this error message: CDO.Message.1 error '80040220' The "SendUsing" configuration value is invalid. /mailplay.asp, line 63
5
8002
by: Pete Loveall | last post by:
I have a server application that monitors a private local queue for messages. The message sent to it has a label and a response queue defined. It works correctly when the queue is accessed via another program. However, when I attempt to Send a message from an ASP.NET VB page, I get "One or more of the passed properties are invalid." I have tried different combinations of the non-transactional Send() with no success. My Windows\Temp...
0
1069
by: John Sutter | last post by:
I want to send emails that show up as html in the mail client including images plus an alternative text for non html capable mail clients. I know that the MailMessage class creates its own text part from the html but I don't want do that because its probably won't look right so I want to add my own text version. I tried to send a message where the body is a pure html string but Outlook didn't render it but showed the html tags. I did use...
10
8943
by: Aj Blosser | last post by:
Hey guys, I have a question for you, I have a setup where I'm sending files through the POST to a php web page, I read the file contents, put that file contents as text into the POST string, and send it on it's way. it works perfectly for text files. However, I can't open a word document like a text file and have it give me the result I need. I'm looking for a way to just open a word document and get all the values in it like you would...
0
2412
by: howardr101 | last post by:
Hi, Have hunted around on the groups and can't find anything, hence. I've tried this against 2 mail servers (mailtraq and hmailserver) and it occus with both. The problems seems to be that when the SMTPClient attaches to the server and the server sends it greeting message, if anything other than +OK is received by the client it throws an exception and falls over.
3
8188
by: Dave | last post by:
string m_request = some_web_page; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(m_request ); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Which works fine, but I need to set and send a cookie with the WebRequest. How do I do that?
4
3823
by: gurufordy | last post by:
Hello. Trying to use the ASP.net user functionality but it keeps failing on me. I have created a login and registration page for my site. When you fill in the registration form it should send a confirmation email with a link to activate the account. Nothing hi-tech here. However, it fails to send the email and provides the following error message: Transaction failed. The server response was: sorry, the sender name and auth login doesn't...
1
3443
by: toretto | last post by:
Hello, I have a script php that I use on my website to permit visitors to send me some email with some data, this is the html table code: <table width="730" border="0" cellpadding="0" cellspacing="0"> <tr> <td><div align="center" class="textorange1"><strong>Richiesta Ricarica</strong></div></td> </tr> <tr> <td>&nbsp;</td>
0
9684
marktang
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...
0
9530
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,...
0
10459
Oralloy
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...
0
10236
jinu1996
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...
1
10182
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,...
0
5445
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...
0
5577
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4120
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
2
3734
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.