HP 800 ACSE/Presentation and ROSE Interface Programmer's Guide - Page 57

Changing Modes

Page 57 highlights

Programming Guide 4. Using Synchronous vs. Asynchronous Mode If ap_rcv() is called in asynchronous mode, data is read from the communication endpoint until either: • the entire primitive is received • the ubuf argument buffer is full • no more user data is available. In the second case, the AP_MORE bit is set in the flags parameter of ap_rcv(). If the AP_MORE bit is set, a primitive was partially received. To receive the rest of the primitive, the ap_rcv() must be re-invoked until the call returns successfully. In the third case: • Either ap_rcv() returns successfully with the AP_MORE bit set and ubuf is partially filled. In this case, to use the remaining ubuf space for the next ap_rcv() you must re-adjust ubuf->len. • Or, ap_rcv() returns unsuccessfully with ap_errno set to AP_AGAIN. In this case, you must not alter any parameters for the next ap_rcv(). Refer to the discussion in the ap_rcv() manpage for more information. Check the sptype after each ap_rcv() call. Some primitives such as A_ABORT_IND are not flow-controlled and may interrupt the receipt of a partially received primitive. In this case, the remaining data of the original primitive is lost. Note that ap_rcv() may still be blocked by running in asynchronous mode in memory shortage situations such as when using large numbers of connections. Changing Modes Once a communication endpoint has been opened using synchronous mode, it can be changed to asynchronous mode in the application by setting the AP_STREAM_FLAGS attribute with AP_NDELEY. However, to reset the execution to synchronous mode, the communication endpoint must be closed and reopened without using O_NDELEY in the ap_open() call. Chapter 4 57

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109

Chapter 4
57
Programming Guide
4. Using Synchronous vs. Asynchronous Mode
If ap_rcv() is called in asynchronous mode, data is read from the
communication endpoint until either:
the entire primitive is received
the ubuf argument buffer is full
no more user data is available.
In the second case, the AP_MORE bit is set in the flags parameter of
ap_rcv(). If the AP_MORE bit is set, a primitive was partially received.
To receive the rest of the primitive, the ap_rcv() must be re-invoked until
the call returns successfully.
In the third case:
Either ap_rcv() returns successfully with the AP_MORE bit set and
ubuf is partially filled. In this case, to use the remaining ubuf space
for the next ap_rcv() you must re-adjust ubuf->len.
Or, ap_rcv() returns unsuccessfully with ap_errno set to AP_AGAIN.
In this case, you must not alter any parameters for the next ap_rcv().
Refer to the discussion in the ap_rcv() manpage for more information.
Check the sptype after each ap_rcv() call. Some primitives such as
A_ABORT_IND are not flow-controlled and may interrupt the receipt of
a partially received primitive. In this case, the remaining data of the
original primitive is lost.
Note that ap_rcv() may still be blocked by running in asynchronous mode
in memory shortage situations such as when using large numbers of
connections.
Changing Modes
Once a communication endpoint has been opened using synchronous
mode, it can be changed to asynchronous mode in the application by
setting the AP_STREAM_FLAGS attribute with AP_NDELEY.
However, to reset the execution to synchronous mode, the communication
endpoint must be closed and reopened without using O_NDELEY in the
ap_open() call.