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

Using Synchronous vs. Asynchronous

Page 56 highlights

Programming Guide 4. Using Synchronous vs. Asynchronous Mode 4. Using Synchronous vs. Asynchronous Mode ACSE/Presentation supports both synchronous and asynchronous mode execution of calls. In synchronous mode, an ACSE/Presentation call blocks until the call can be completed. While blocked, no other tasks can be performed. Synchronous mode is the default. In asynchronous mode, an ACSE/Presentation call is not blocked (except under kernel resource shortages). The function completes as much of its task as it can, then returns to the user. Synchronous Mode Synchronous mode is useful for processes maintaining a single connection, and for processes that can wait for events to occur. When synchronous mode is used, ap_snd() blocks until resources are available to send the entire primitive. Similarly, ap_rcv() blocks until either an entire primitive is received, or the user buffer is filled by the library. In the latter case, ap_rcv() returns with the AP_MORE bit set in the flags argument. To receive the remaining data, the application must continue to call ap_rcv() until it returns with the AP_MORE bit reset. Asynchronous Mode Asynchronous mode is used for applications in which long delays are expected between events, and for processes that can perform other tasks while waiting for events to happen. Asynchronous mode is also useful for managing multiple connections concurrently. Asynchronous mode is specified in ap_open() by setting the O_NDELAY bit in the oflags parameter. When used asynchronously, ap_snd() and ap_rcv() do not block in most cases. If there are insufficient resources from OTS to send the entire primitive for an ap_snd(), a partial send can occur. A return code of -1 is received and ap_errno is set to AP_AGAIN. To complete sending the primitive, ap_snd() must be invoked again with the same set of buffers and arguments until the call returns successfully. 56 Chapter 4

  • 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

56
Chapter 4
Programming Guide
4. Using Synchronous vs. Asynchronous Mode
4. Using Synchronous vs. Asynchronous
Mode
ACSE/Presentation supports both synchronous and asynchronous mode
execution of calls. In synchronous mode, an ACSE/Presentation call
blocks until the call can be completed. While blocked, no other tasks can
be performed. Synchronous mode is the default.
In asynchronous mode, an ACSE/Presentation call is not blocked (except
under kernel resource shortages). The function completes as much of its
task as it can, then returns to the user.
Synchronous Mode
Synchronous mode is useful for processes maintaining a single
connection, and for processes that can wait for events to occur.
When synchronous mode is used, ap_snd() blocks until resources are
available to send the entire primitive. Similarly, ap_rcv() blocks until
either an entire primitive is received, or the user buffer is filled by the
library. In the latter case, ap_rcv() returns with the AP_MORE bit set in
the flags argument. To receive the remaining data, the application must
continue to call ap_rcv() until it returns with the AP_MORE bit reset.
Asynchronous Mode
Asynchronous mode is used for applications in which long delays are
expected between events, and for processes that can perform other tasks
while waiting for events to happen. Asynchronous mode is also useful for
managing multiple connections concurrently.
Asynchronous mode is specified in ap_open() by setting the O_NDELAY
bit in the oflags parameter. When used asynchronously, ap_snd() and
ap_rcv() do not block in most cases.
If there are insufficient resources from OTS to send the entire primitive
for an ap_snd(), a partial send can occur. A return code of -1 is received
and ap_errno is set to AP_AGAIN. To complete sending the primitive,
ap_snd() must be invoked again with the same set of buffers and
arguments until the call returns successfully.