• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
[Repost] OTCountFreeBytes? (like OTCountDataBytes but for send)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Repost] OTCountFreeBytes? (like OTCountDataBytes but for send)


  • Subject: [Repost] OTCountFreeBytes? (like OTCountDataBytes but for send)
  • From: Mike Kluev <email@hidden>
  • Date: Thu, 31 Jan 2002 20:41:40 +0300

Hi,

I need to determine how much could I send with OTSnd without
blocking and without getting back "partial success" error or
flow-control error. This will greatly simplify the logic of
my program and will be usefull in both synchronos blocking
and asynchronous blocking case. There is OTCountDataBytes but
it is usefull only to determine how much could I read; I am
looking for analog of it to determine "how much could I write".

// imaginary "OTCountFreeBytes" call usage
// Async blocking case

if (OTCountFreeBytes(ep) >= size) {
OTSnd(ep, data, size, 0);
}
else {
// just skip to send this time
// The nature of this program is such that it is permissable to
// skip sending data packet. (The packet should be either sent
// *as a whole* or not sent *as a whole*
}

Sure, there is workaround:

===
// Async blocking case
DoSend():

1. Try to send (result = OTSnd).

2. If success (i.e. result == bytes sent) - done.

3. If partial success (i.e. result < bytes sent) goto (1)

4. If flow-control error, remember what to send, return
done to caller. 'T_GODATA' event will eventually happen.

5. If kOTOutOfMemoryErr, remember what to send and prime timer
proc to send later. return done to caller.
(BTW, how often is this situation? Could I presume
that its probability is close to zero and just treat
as as rare fatal error?)

6. If look error - call OTLook and report to caller

7. If other error - report to caller.

8. If result = 0
(BTW, could it ever happen? If bytes sent <> 0?
If bytes sent = 0?) treat it as (3) (or 2?)

9. If result > bytes sent (BTW, could it ever happen?)
treat it as (3) (or 7?)


Notifier()
{
...
case T_GODATA:
case T_GOEXDATA:
recall the data remembered and DoSend again.
break;
...
}

Timer()
{
...
recall the data remembered and DoSend again.
...
}
===

But, as I've already said, in this particular application the
datum is not that critical so if I can't send the whole packet
(for whatever reason) it is safe just to skip it (as a whole):

===
// Async blocking case
if (OTCountFreeBytes(ep) >= size) {
OTSnd(ep, data, size, 0);
}
else {} // just skip
===

Compare this to the above - it is much simpler.

In this particular program there is only one "sender", so if
there was a call "OTCountFreeBytes" the value that it returns
could be either exact free bytes or larger (never smaller),
when the OTSnd call is actually executed, because it could
only get smaller if someone sends data, but in this case there
is only one such a sender.

The question is: is there a way to achieve this under OT?

Regards,
Mike Kluev


  • Follow-Ups:
    • Re: [Repost] OTCountFreeBytes? (like OTCountDataBytes but for send)
      • From: Quinn <email@hidden>
  • Prev by Date: Re: PPPoE and PPPoA as Modem Driver
  • Next by Date: Re: [Repost] OTCountFreeBytes? (like OTCountDataBytes but for send)
  • Previous by thread: Re: PPPoE and PPPoA as Modem Driver
  • Next by thread: Re: [Repost] OTCountFreeBytes? (like OTCountDataBytes but for send)
  • Index(es):
    • Date
    • Thread