Sending data with CAsyncSocket.

Please tell me if/where I am wrong...

If I have an established TCP connection using CAsyncSocket...

When I send data I will normally be sending a packet that is about 100 bytes 
or so. I would send each packet with a separate call to "Send". Normally the 
Send will return a value equal to the number of bytes I sent. I would just 
write my code to call Send whenever I need to send a packet.

Normally I would never receive an error or an indication that fewer bytes 
were sent. But if I did, I would handle this error.

There is no need for me to use the "OnSend" function. Correct? 


0
TonyG2127 (95)
5/26/2005 2:57:17 PM
vc.mfc 33608 articles. 0 followers. Follow

3 Replies
445 Views

Similar Articles

[PageSpeed] 19

Normally no one would ever get an error. It's only when things aren't
normal. :-o

you should handle Send returning less than what you are trying to send.
beside all the other errors that could happen.

   long Transmited = 0;
   while (Transmited < BufferSize)
   {
      long Sent = 0;
      Sent = CSocket::Send(pBuffer+Transmited,BufferSize-Transmited);
      if (Sent == SOCKET_ERROR)
      {
            DWORD Error = GetLastError();
            switch (Error)
            {
              //handle the error here
            }
      }
      Transmited += Sent;
   }

AliR.

"TonyG" <TonyG@junk.com> wrote in message
news:htlle.2567$3D6.2334@newssvr12.news.prodigy.com...
> Please tell me if/where I am wrong...
>
> If I have an established TCP connection using CAsyncSocket...
>
> When I send data I will normally be sending a packet that is about 100
bytes
> or so. I would send each packet with a separate call to "Send". Normally
the
> Send will return a value equal to the number of bytes I sent. I would just
> write my code to call Send whenever I need to send a packet.
>
> Normally I would never receive an error or an indication that fewer bytes
> were sent. But if I did, I would handle this error.
>
> There is no need for me to use the "OnSend" function. Correct?
>
>


0
AliR1 (391)
5/26/2005 3:23:17 PM
Thanks,  I will look into it further.

Scott... Do you have any comments on my other post "Trying to understand 
CAsyncSocket"? That is where I am really confused. 


0
TonyG2127 (95)
5/26/2005 9:54:27 PM
TonyG wrote:
> Please tell me if/where I am wrong...
> 
> If I have an established TCP connection using CAsyncSocket...
> 
> When I send data I will normally be sending a packet that is about 100 bytes 
> or so. I would send each packet with a separate call to "Send". Normally the 
> Send will return a value equal to the number of bytes I sent. I would just 
> write my code to call Send whenever I need to send a packet.
> 
> Normally I would never receive an error or an indication that fewer bytes 
> were sent. But if I did, I would handle this error.
> 
> There is no need for me to use the "OnSend" function. Correct? 
> 
> 

Depending on how you write your code, it can be quite important to use 
the OnSend function.  It represents part of a flow control handshake 
that you must support one way or another.

If you try to send data faster than the connection or client can accept 
it then Send will return WSAEWOULDBLOCK.  This is not an error but a 
notification that you must wait a while.  OnSend is the notification 
that "a while" has passed and you can send some more.

-- 
Scott McPhillips [VC++ MVP]

0
Scott
5/26/2005 10:48:09 PM
Reply:

Similar Artilces:

sending mail using an alias email address
We are using Exchange Server 2007 with Outlook 2007 clients. I have several email addresses listed under my mail account on the Exchange Server for which I "receive" email. However, the server will not allow me to "send" email using any of these email addresses - as it only allows me to send using the primary address for my email account. I get a message saying "You are not allowed to send this message ... on behalf of another sender without permission to do so." What settings do I need to change on the Exchange Server so that it allows Outlook 2007 ...

WM_QUERYENDSESSION and saving data through a worker thread
Hello I have an application that uses a worker thread to save/load data. I'm wondering what is the best reaction to WM_QUERYENDSESSION in my case. I have to possible scenarios: 1. When WM_QUERYENDSESSION comes fire the thread and wait for it to end. Only then return TRUE from WM_QUERYENDSESSION handler. The problem is that I will get nusty dialog that my application "is not responding". 2. When WM_QUERYENDSESSION comes fire the thread and return FALSE from the handler. When thread is done force application to end. But this way I will probably prevent Windows from closing,...

Copying data from one chart to another
I have many graphs - all plotting on similar scales but using different data. Is there any way I can simply copy one set of data from one graph and paste it into another graph so that I can avoind going through all the hassle plotting each curve again? I want to have graphs showing different combinations of the same data and have hundreds of curves to plot so this could be a huge timesaver... Cheers. -- Alan_Partridge ------------------------------------------------------------------------ Alan_Partridge's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=29295 V...

Possible to send email directly to a folder?
I know I've seen this done but I cannot remember how to send email to a folder by using its address in the CC: block.... When sending email, how can I also include the "address" of an OL folder in one of my open PSTso it automatically receives a copy of the email (much like Sent Items)? How about to my OL folders in my Exchange server? I have some templates filled with about 90% of what I have to send on a recurring basis, and preconfiguring the folder where I copy these (ffor later reference) would save me some work. I can swear I did this before but cannot find it now. TI...

Can I abbreviate one value in a data series?
I've got a chart where one value (8,300) greatly exceeds all the others. Is there a way to abbreviate this value so the other data points show better in the graph? Hi, One way is to break the Y axis, have a look at these examples of how to http://peltiertech.com/Excel/Charts/BrokenYAxis.html http://tushar-mehta.com/excel/newsgroups/broken_y_axis/tutorial/index.html http://www.andypope.info/charts/brokencolumn.htm Cheers Andy CMEknit wrote: > I've got a chart where one value (8,300) greatly exceeds all the others. Is > there a way to abbreviate this value so the other da...

How can I clear the last Data->Text to columns to formatting
I've noticed in Excel 2000 that if I paste text into various worksheets within a workbook each paste will assume the Text->Column formatting that I applied in the previous. How can I prevent it from happening ? Thanks Steve Just run another data|Text to columns against a dummy cell. Specify delimited, but remove all the check marks from all the possible delimiters. (alternatively, you can close excel and reopen it.) svaardt wrote: > > I've noticed in Excel 2000 that if I paste text into various worksheets > within a workbook each paste will assume the Text->Col...

Outlook 2003 wont send email-very weird
Greetings. Last month installed Outlook 2003(Office 2003 Teacher/Student edition) The other day I found out that email I have been sending have not really been sent. Did some tests. Email goes into outbox fine. Email sends and then goes into my sent box. BUT, it never really gets sent. I have tested this many times. All the email in my sent box never actually goes anywhere. I have setup Outlook Express and it sends email with my ISP just fine. I have done a TEST AND REPAIR to no avail I have installed all updates to no avail I have uninstalled Outlook 2003 and reinstalled it to no ava...

Can't send from OWA
Hello all, I have an 03 Exchange environment and am using the forms based authentication through an ISA 04 server for my OWA. I have a number of employees that work around the world and use OWA in order to access their e-mail. I have received reports of problems from a few of these individuals when trying to send an e-mail. They are able to successfully login to OWA but when they generate a new mail message, they receive the following error. 'Check Names.. Web Page Dialog Microsoft Outlook Web Access does not recognize "user@domain.com" Do you want to Delete this recipi...

Cannot send delivery receipts
I have an Exchange server 2003. While I am able to send non-delivery reports (NDR) and read receipts, I am unable to send delivery receipts. That is not exactly correct. I can send delivery receipts to email addresses from within my domain, if the email orginates from within my domain. When the email originates from outside of my domain, there is no delivery report sent, or at least received. In the Exchange System Manager, under Global Settings, the default properties under the advanced tab for the Internet Message Formats is set to allow delivery reports. In the Internet Mail SMTP Conn...

Remote users cannot send e-mail through Outlook
I have a few users who do not work in our office. They have Outlook installed on their home computers and then dial up to the internet and do a send/receive. I have Exchange 2k3 on a Windows 2k server and the users are configured to allow for SMTP/POP3. All was working fine until earlier this week when they informed me that they could no longer "send" mail. They get the message "The TCP/IP connection was unexpectedly terminated by your mail server. If this problem persists, contact your LAN Administrator or Internet Provider". The users can still receive mail ...

Event ID 1016 logged for sending an email
I recently emailed a co-worker (at 11:42am). I was then later shown a security log that showed Event ID 1016 was logged at 11:42am saying that I accessed her mailbox. I did no such thing! I've researched the knowledgebase and found some info on this topic, but can anyone tell me how I can definitively clear my name? Has this happened to anyone else - simply sending an email caused 1016 to log? I realize that checking the other person's calendar could also do this, but I don't think I did that either. My job could be on the line. Thanks for any help you can provide. (...

Outlook won't send CC's
I responded to an email with a group of cc's (reply all) and the mail wouldn't leave the outbox until I moved all of the cc people to the top reply line. What is blocking send out cc's? Thank you. I can't imagine. Did Outlook return an error with a send/receive initially? "its_my_dime" <its_my_dime@yahoo.com.spam (hold the .spam)> wrote in message news:OqtFqtT1GHA.4108@TK2MSFTNGP04.phx.gbl... >I responded to an email with a group of cc's (reply all) and the mail >wouldn't leave the outbox until I moved all of the cc people to the top ...

Relaying denied / Can't send to aol.com & cisco.com domains
We have 1 internal Exchange 2000 server for our only domain, dortfcu.org. When we try to send an email to anyone at the aol.com or cisco.com domain, their email server says 550 5.7.1 <email address>... Relaying denied. I think the issue is a dns issue and is due to the fact that I upgraded one of our 2 dns servers from windows 2000 server to windows 2003 server last weekend. NSLOOKUP of dortfcu.org with type=mx says that mail exchanger = smtp.dortfcu.org. The servers real name is dort2.dortfcu.org. So I guess this means my mx record is wrong? I don't have access to my ...

How do I import data from lotus123 & maintain formulas/worksheets
I am trying to convert several complex Lotus 123 workbooks with formulas into Excel 2003. How do I do this and maintain my formulas and the individual tabs (worksheets). hi, if the lotus file is a wks version or earlier, xl should open it and let you save it as an xl file. if the lotus file is a 123 version or higher, you can open the file in lotus and save it as an xl file. if you don't have lotus, find someone who does. "Ineluctable" wrote: > I am trying to convert several complex Lotus 123 workbooks with formulas into > Excel 2003. How do I do this and maintai...

sending mail 05-20-10
The message could not be sent. The authentication setting might not be correct for your outgoing e-mail [SMTP] server. For help solving this problem, go to Help, search for "Troubleshoot Windows Mail", and read the "I'm having problems sending e-mail" section. If you need help determining the proper server settings, please contact your e-mail service provider. The rejected e-mail address was 'michael.porth@bafin.be'. Subject 'Hello', Account: 'pop-server.tampabay.rr.com', Server: 'smtp-server.tampabay.rr.com', Protocol: SMT...

obtaining data in text form from a table
Hi all, I like to be able to obtain the dates in a text format from the table below. ie Test2 8-Feb Test5 4-Feb,8-Feb Test6 4-Feb,5-Feb, 9-Feb Do I need to do this by macros and if so, any help would be appreciated. Table Care Recipient Surname 4-Feb 5-Feb 8-Feb 9-Feb Test1 Test2 8-Feb Test3 Test4 Test5 4-Feb 8-Feb Test6 4-Feb 5-Feb 9-Feb Vlookup should do what you want, as in: =vlookup(a2,Table,2,false) Adjust the ranges t...

Determine number of rows with data
Hi I am using the macro below to pull some data from an external workbook. The 2 issues I need to sort are: 1. The number of rows in the external workbook can vary. How do I amend this code to pull all of the rows with data? 2. The number of rows in the autofill also may vary. How do I autofill only the number of rows required? i.e the number of rows in column A that contain data. 'Lookup Previous Month Sales Columns("K:K").Select Selection.NumberFormat = "General" Range("K4").Select Selection.FormulaArray = _ "=S...

Delete contents deletes all data and formulas
When I hit delete contents all data and formulas are deleted. How can I delete data without deleting formulas? Hi, You could try this tap F5 - Special - Constants - OK and if that selects the data you want to delete then tap the delete key -- Mike When competing hypotheses are otherwise equal, adopt the hypothesis that introduces the fewest assumptions while still sufficiently answering the question. "tdhcrr" wrote: > When I hit delete contents all data and formulas are deleted. How can I > delete data without deleting formulas? First use Find...

Send Url via workflow
Hello, the problem am facing is that I want to be able to send an URL via a workflow to be opened by a web browser. Can you please help me? example: i want the workflow, as soon as the appointment finishes, to open a URL (http://www.google.com) On Aug 6, 6:58=A0pm, Ali BARADA <a.bar...@gmail.com> wrote: > Hello, > the problem am facing is that I want to be able to send an URL via a > workflow to be opened by a web browser. Can you please help me? > > example: i want the workflow, as soon as the appointment finishes, to > open a URL (http://www.google.com) Given workf...

trying to send out emails
Operating System: Mac OS X 10.5 (Leopard) Processor: Intel Email Client: pop I am trying to send emails from my entourage account and each time an error message appears telling me- <br> Entourage cannot find the server. Verify the server information is entered correctly in account settings, and that your DNS settings in the network pane of system are correct. <br> I am not sure how to fix this please help. <br> Rebecca On 2010-01-28 10:18:12 -0500, reisrl15@officeformac.com said: > I am trying to send emails from my entourage account and each time an > e...

Bulk sending of emails in Outlook being rejected if one address is wrong.
I am sending bulk emails in BCC and they are all being returned to me because one or more of the email addresses is incorrect. Is there a way to setup Outlook so that the emails go to the correct addresses and the incorrect addresses are bounced back to me? I use the Mail Merge feature and send out a newsletter with over 1000 e-mail addresses (who signed up for the newsletter so it is not spam). My service provider, Comcast, just put a limit of 10 at a time. It's real fun sending these out monthly!! >-----Original Message----- >I am sending bulk emails in BCC and they a...

Send notification email when timesheet is rejected
Hi, Is there any way to send email notification to a resource when a time sheet is rejected by the resource manager or project manager. We're using WSS 3.0 and Project server 2007. I can find alerts for task and other items but i don't find any sort of help regarding this issue Thanks in Advance. There is no way to do this without some sort of customization. You might want to post this question in the microsoft.public.project.developer newsgroup. Jonathan "rajeshts" <rajeshts@discussions.microsoft.com> wrote in message news:A4A692A8-C41C...

Add data to cell w/o loosing initial data
I would like to know if there is a way to add data to data without retyping. For example I have a colum of 18015555555 and I want to add [rfax:(cell #)@/fn=(phone number)] So I would like to add the brackets - copy from a cell - @/fn= and not loose the data already in the spread sheet. Example 2. Add [rfax:company name@fn/=(saved data here) then close bracket. So I want to add data to cells without loosing the data already in the cells. I have about 600 of them to do and I really don't want to do each one by hand. Please let me know if anyone knows how to accomplish this. Tha...

Removing filters from data
Hi. I have recorded a macro to remove filters from data lasts in advance of performing other actions. However if the data is unfiltered the macro falls over with the message Run time error '1004' ShowAllData method of Worksheet class failed. I think I need some sort of if error continue code or something to check filtering first. I would be grateful if someone could point me in the right direction please. Hi Philip Try If Activesheet.Filtermode Then ActiveSheet.ShowAllData -- Jacob "Philip J Smith" wrote: > Hi. > > I have re...

Looking up and matching data
I have two sets of data with the same information but not in the same order and am trying to match the data. In each data set I have 10 pools containing 100 loans. Each pool has a unique ID and each loan within the applicable pool has an ID of 1 to 100. I need to look up the Pool ID, then look up the loan ID so that I can extract the property type information from a third column. The Pool ID and property type is text but the loan ID is a number. I am struggling to put together the right combination of formulas to give the property type for each loan within each pool. Any suggestion...