Problems with CAsyncSocket::Send.

I am using CAsyncSocket to create a TCP server. My class accepts client 
requests and I create client "worker" classes for each connected client. 
Sometimes I have problems when I send data to the client. I think this is 
because I don't understand what I should be doing.

Currently in the client class, to send data, I just call CAsyncSocket::Send. 
It usually works, but sometimes it returns SOCKET_ERROR and GetLastError 
indicates WSAEWOULDBLOCK.

I look through the MFC documentation and I think I should be using OnSend 
somehow. But I don't know the details.

Can someone please tell me what I should do. 


0
TonyG2127 (95)
7/13/2006 9:44:23 PM
vc.mfc 33608 articles. 0 followers. Follow

3 Replies
1595 Views

Similar Articles

[PageSpeed] 20

TonyG, this clases could help you:
http://www.codeproject.com/internet/ndk.asp

William GS
0
WilliamGS (26)
7/13/2006 11:38:58 PM
TonyG wrote:
> I am using CAsyncSocket to create a TCP server. My class accepts client 
> requests and I create client "worker" classes for each connected client. 
> Sometimes I have problems when I send data to the client. I think this is 
> because I don't understand what I should be doing.
> 
> Currently in the client class, to send data, I just call CAsyncSocket::Send. 
> It usually works, but sometimes it returns SOCKET_ERROR and GetLastError 
> indicates WSAEWOULDBLOCK.
> 
> I look through the MFC documentation and I think I should be using OnSend 
> somehow. But I don't know the details.
> 
> Can someone please tell me what I should do. 


When you get WSAEWOULDBLOCK the winsock buffers or network or receiving 
machine is busy.  It is a form of throttling that means 'wait a while.' 
When you get the call to OnSend it means you can resume sending.  Then 
you can once again send all you like, as many times as you like, until 
another WSAEWOULDBLOCK happens.

-- 
Scott McPhillips [VC++ MVP]

0
Scott
7/14/2006 12:03:39 AM
Thanks, I think I understand what needs to be done.


"Scott McPhillips [MVP]" <org-dot-mvps-at-scottmcp> wrote in message 
news:OkH%23nktpGHA.4196@TK2MSFTNGP04.phx.gbl...
TonyG wrote:
> I am using CAsyncSocket to create a TCP server. My class accepts client
> requests and I create client "worker" classes for each connected client.
> Sometimes I have problems when I send data to the client. I think this is
> because I don't understand what I should be doing.
>
> Currently in the client class, to send data, I just call 
> CAsyncSocket::Send.
> It usually works, but sometimes it returns SOCKET_ERROR and GetLastError
> indicates WSAEWOULDBLOCK.
>
> I look through the MFC documentation and I think I should be using OnSend
> somehow. But I don't know the details.
>
> Can someone please tell me what I should do.


When you get WSAEWOULDBLOCK the winsock buffers or network or receiving
machine is busy.  It is a form of throttling that means 'wait a while.'
When you get the call to OnSend it means you can resume sending.  Then
you can once again send all you like, as many times as you like, until
another WSAEWOULDBLOCK happens.

-- 
Scott McPhillips [VC++ MVP]


0
TonyG2127 (95)
7/14/2006 12:42:01 AM
Reply:

Similar Artilces:

When someone send a mail make a copy in a mailbox.
Hi! How can I do that? I wan to make a copy message in a mailbox, when somebody send a mail to somebody? And I want it with all mailboxes. Thanks in advance Hi, what Exchange version are you using? -- Keep on fighting! Christian Please reply to this message, to let others know whether it was useful to help you solve your problems or not. Original Message: "Corner" <corner@t-email.hu> wrote in message news:uPFJa6hfEHA.3556@TK2MSFTNGP12.phx.gbl... > Hi! > > How can I do that? I wan to make a copy message in a mailbox, when somebody > send a mail to somebody?...

Problem on sending emails
Hello. I have an asp.net, that sending emails. I have the following code : Dim mail As New MailMessage Dim smtp As New SmtpClient("my-site.org") smtp.Credentials = New NetworkCredential("admin@my-site.org", "myPassowrd") mail.From = New MailAddress("admin@my-site.org") mail.To.Add("support@my-site.org") mail.Subject = "Contact" mail.Body = "<html> <body>...</body> </html>> mail.IsBodyHtml = true smtp.Send(mail) Ev...

send email as a delegate
I get an error message "You do not have the permission to send the message on behalf of the specified user", when I try to reply as a delegate. Any suggestions ...

Problem starting different http connections from the same application
Hi, I have a multithreaded application in which one thread sends a request to a web server -and reads the response for a while (which is why its a separate thread). The other thread needs to send data periodically to the server - but this is where I run into problems. In the method that the second thread uses makes a new session , gets a new connection, creates a new http file - but fails to send the data. Looking at the ethereal captures, it seems that the second thread is sending requests through the same tcp connection that the very first request (that hasn't returned yet) we...

external application sending email through outlook
Ever since Security Patch for Outlook 2000, a popup dialog box appears stating that an external app is attempting to send email... yes/no.. etc. Is there a way to 'define' applications that are allowed to send email through the MAPI interface..?? More info here: http://www.slipstick.com/outlook/esecup.htm -- PATRICK REED [Outlook - MVP]~~~~~~ -Microsoft Certified Professional (MCP) -Have you checked http://www.slipstick.com? -Please post your Outlook version! "Brent Morehouse" <brent_morehouse@hotmail.com> wrote in message news:01db01c3bb58$4132568...

550 5.7.1 error when others send email to us
We have Exchange 2003 and have two domains set up and they have been working fine for years. We recently added a third domain but senders to this domain get a "remote host said: 550 5.7.1. Unable to relay" when they send email to it. The new domain has been added under recipient policy and the mx records are correct. All our IT professionals have been scratching their heads over this one....please help! Go into your recipient policy and edit the new address. Make sure that the box is checked that states "This Exchange Organization is responsible for all mail deliver...

GP10 Smartlist problem output to Excel 2010
When we see the listing in the Smartlist, we click the button with Excel logo, to export the listing to Excel, but GP prompt with error message :Unable to start Microsoft Excel http://img137.imageshack.us/img137/4100/errorw.png This is the newly purchased workstation. This is the first computer that is come with Microsoft Office 2010 version, the rest are still using Office 2007. And this new computer has never been successfully launched Excel from the Smartlist. We are wondering if the Office 2010 STARTER edition can work work with Dynamics GP 10 with FP1 SP4. Please advice ...

Combo Box problem 02-15-10
Hi I have 3 tables and 3 associated forms in an 2007 access database. On each form is a combo box "Name Search" so that one can input 2 or 3 letters of a surname and get a drop down list of names matching the input. All three Combo Boxes were set up in an identical manner using the wizard. The Main Menu has three buttons where you choose which table (or dbase) you wish to query. I now have a situation where 2 of the 3 combo boxes will not accept input (i.e. do not work) If I copy the Row Source from the one combo box that always works to one of the other two...

Problem in Microsoft Outlook Express
Dear, I have a problem in Microsoft Outlook Exprees, the problem is that when i want to see the attachment attached with my receiving mails, the paper clip sign shows but when i tried to open it the attached file is not highlighted another thing is that when i tried to forward that attachment, the attachment is glow and it can be open what can i do? Hi Ahmer - This is a group to support Outlook from the Office group of programs. Outlook Express is a part of Internet Explorer and is a quite different program, despite its similar name.. You will probably get a faster and more expert an...

Problems with printing booklet
My printer stopped after printing page 1 & 4 of a booklet (outside and back cover). I tried to print the inside of the booklet (page 2 & 3), but it does not print it correctly. Does any one have an idea of what to do? Thanks. Hi Glenn Thomas (glennt@jam.rr.com), in the Microsoft� newsgroups you posted: || My printer stopped after printing page 1 & 4 of a booklet || (outside and back cover). I tried to print the inside of || the booklet (page 2 & 3), but it does not print it || correctly. Does any one have an idea of what to do? Thanks. Can you tell us what doesn't pri...

can't send messsages in window mail
I keep getting an error code (0x800cccD) and yet i can recieve mail in the sme ppage Please post the error message in its entirety. You can left click on it to highlight and then right click to copy and then paste it into this thread. -- Bruce Hagen MS-MVP [Mail] Imperial Beach, CA "Lonnie" <Lonnie@discussions.microsoft.com> wrote in message news:12CAB0C7-C8EE-4B3D-8099-23F52C9930C6@microsoft.com... >I keep getting an error code (0x800cccD) and yet i can recieve mail in >the > sme ppage I tried moving all mess...

Outlook XP and Windows ME Problem
Hi, I am running Outlook XP on Windows ME. All of a sudden when I try to download mail, the progress bar comes and says receiving 0 of 97 messages and just hangs there. After a while the whole outllok and my computer is not responding. Any ideas on why it is happening or how it can be resolved? ...

Problem with Instantiating classes
I converted an Access MDB multi-user application to a client/server application. The classes are no longer working. I checked to see if a variable was declared using the class name and then I checked to make sure that the class is instaniated by setting it equal to a New Class Instance. I keep getting an Error 91. If I set the instantiation in a loop for two to three times to instantiate the class it works fine. Has anyone run into this type of problem? ...

Strange problem about register window class
I want to register two window class in winmain.But when registering the second window class,VC7.0 reports an error.The error code is 87 - parameter error.But the parameters of both WINCLASSEX are the same except the wndproc and wndclass name. When compiling with bcc55,it's OK.When compiling with cygwin-g++-4.1.2 it's the same as VC7.0. If assign wc.hInstance with reinterpret_cast<HINSTANCE>(&hInstance) ,it's OK.Why?What does &hInstance mean? Below is the code: // cl register.cpp -link gdi32.lib user32.lib // g++ -o register.exe register.cpp -mwindows #include <...

problem Adding new user on server 2003
I can't not add any user the program is giving me a masege: Windows unable to update the password. The Value provided for the new password does not meet the length, complexity, or history requirement of domain. please help.. I can not add any users becouse of this message. You have complex passwords enabled, so the users password must be a certain length and contain upper-case, lower-case and numerical values. -- Mark Fugatt Exchange MVP http://www.exchangetrainer.com http://www.msexchange.org "oscar" <oscar@tvpromofl.com> wrote in message news:098701c3d3b4$3dfa3e50...

can't send replies to msgs
Try to send a reply to a received message and computer freezes? Whats up? We'd need a lot more info to help you - version of Outlook, SP level, type of email account, how big is your PST file? anonymous@discussions.microsoft.com wrote: > Try to send a reply to a received message and computer > freezes? Whats up? ...

Problem enabling a button in a toolbar
Hi all.. First of all, this is a MDI application in Visual C++ 6.0. I have a docking control bar that contains a dialog. I placed a toolbar on that dialog with one button at the moment. The problem I have is that I could never enable the button. I tried WM_KICKIDLE message but even when it is received correctly by the dialog, and enabling the button there, it continues appearing disabled. The button has its handler in the dialog (since it is the parent) To make another try, I placed the button handler in the child frame, and the button appears finally enabled, and when I press it, the hand...

Warning Startup form problem
I recently asked a question about using a form to give a warning msg if an event was happening on the day my db was opened. I believe 'Allen' kindly supplied me with the necessary info and the form works fine if there is an event on that day however if there are no events I get nothing at all and would actually like another form/the switchboard to startup?/ I have tried various if statements to no avail can anyone help please. It would really help to see the code you're using to pop up this warning form. -- There's ALWAYS more than one way to skin a cat! Answers/pos...

Outlook XP SP3 and Winmail.dat problem
Hi, any news about RTF editor and Winmail.dat attachment files ? The problem is that if you use RTF or WORD to write emails and you attach some file, the receiver has a Winmail.dat file instead of the original file attached. thanks regards Davide This is normal since RTF is a proprietary format for Microsoft Outlook. Internet Email programs like Pine, Outlook Express, Eudora, The Bat!, .etc can't unwrap the binary stream in order to display the message as it was original formatted. Best option is to switch your message format to plain text or html and consider disabling Word 2002 as ...

Getting external data problem
Hi In the External Data Range Properties, there are 3 options for 'If the number of rows in the data range changes upon refresh:' I want it to stay on option 3 - Overwrite existing cells with new data, clear unused cells. but it keeps defaulting to option2 - Insert entire rows for new data, clear unused cells. I am using Excel 2000 and my data is from Access 97. Any ideas?? Steve ...

WM_MOUSEWHEEL problem!
I created a window as following /////////////////////code m_pSecondWnd = new CWnd; m_pSecondWnd->Create (m_lpszSecondClassName, NULL,WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL, CRect (0,0,0,0),this, 1005); OldProc = (WNDPROC)::GetWindowLong(m_pSecondWnd->m_hWnd, GWL_WNDPROC); ::SetWindowLong (m_pSecondWnd->m_hWnd, GWL_WNDPROC, (long)ScrollProc); /////////////////////code ends However, I cannot catch the WM_MOUSEWHEEL message in the ScrollProc. Why? No one know this? Please google the 100,000 or so web pages on making good newsgroup posts. -- - Mark...

Problem syncing MS Messaging Library to iDisk
Version: 2004 Processor: Intel Since installation of Snow Leopard I get the following message iDisk error message several times per day. I don't know what it means, or what I have to do to correct the problem. The message is:"There is a problem syncing the file 'MicrosoftMessaging Library.bundle1' The destination does not support symlinks. Try compressing the file first." This message is always followed by a nearly identical message that references MicrosoftMessagingLibrary.bundle2. Thannks in advance. Any <Driver_Dude@officeformac.com> wrote: > Since install...

Send/Receive Groups problem
I have two Account Groups set up in Outlook 2003 with the same three email accounts in each.. In the first group, I have Unchecked the option "Include the selected account in this group" for one of the accounts. However, when I do a manual "Send and Receive for that group, it still sends and receives for the unchecked account. And yet the second group, which has the two accounts that are checked in the first group, unchecked, only sends and receives for the one account that IS checked, which is the one that is UNCHECKED in the first group. How come the first group doesn&#...

Importing number format problem in Excel
I am trying to import numbers from a table in Access that is stored as a number format into Excel and Excel does not recognize the numbers as numbers. I have to manually convert the numbers format via the Excel error checking tool everytime. I have this problem when trying to paste any type of number format in Excel. How can I change the default settings in Excel to recognize number formats and automatically paste them in as numbers? I am using Excel XP in case it matters. Thanks Debra Dalgleish has posted a couple of techniques for fixing this after the fact: http://groups.go...

Outlook 2003 Suddenly not sending email with hyperlinks
I have been having trouble sending email (even to myself) that has a signature, or hyperlink in the message. It goes out of the outbox but is never received on the other end. I have tried sending to myself and never get it. If I remove the signature or hyperlink it might work or it might not. Any help out there? No telling who hasn't gotten my emails and I conduct some business through this. Very scary. Laurie "Laulow" <Laulow@discussions.microsoft.com> wrote in message news:5EE2562B-D1FD-404D-8231-230FF8B775C6@microsoft.com... >I have been havi...