User Tools

Site Tools


cdc:nos2.source:nam5871:ippsend

IPPSEND

Table Of Contents

  • [00004] PROC IPPSEND (SOCKID, BUFFER1, BUFLEN1, BUFFER2, BUFLEN2,
  • [00007] IPPSEND - SEND DATA FROM A SOCKET
  • [00048] PROC IMNS
  • [00049] PROC IPINITH
  • [00050] PROC NETPUT
  • [00051] PROC RTIME
  • [00052] PROC XDRBYTE
  • [00053] PROC XDRINT

Source Code

IPPSEND.txt
  1. *DECK IPPSEND
  2. USETEXT TEXTIPL
  3. USETEXT TEXTXDR
  4. PROC IPPSEND (SOCKID, BUFFER1, BUFLEN1, BUFFER2, BUFLEN2,
  5. ADDRESS, SOCKSTATUS);
  6. *CALL COPYRITE CDCNET - COPYRIGHT CONTROL DATA. 1992.
  7. # TITLE IPPSEND - SEND DATA FROM A SOCKET #
  8.  
  9. BEGIN # IPPSEND #
  10. #
  11. **** IPPSEND SEND DATA FROM A SOCKET
  12. *
  13. * THIS PROCEDURE SENDS A BLOCK OF DATA FROM THE SOCKET *SOCKID*
  14. * TO THE HOST AT *ADDRESS*.
  15. *
  16. * PROC IPPSEND
  17. *
  18. * ENTRY SOCKID = INTEGER VALUE OF SOCKET
  19. * BUFFER1 = FIRST BUFFER WHICH CONTAINS THE DATA TO SEND
  20. * BUFLEN1 = NUMBER OF BYTES IN *BUFFER1* TO SEND
  21. * BUFFER2 = SECOND BUFFER WHICH CONTAINS THE DATA TO SEND
  22. * BUFLEN2 = NUMBER OF BYTES IN *BUFFER2* TO SEND
  23. * ADDRESS = 4 WORD DESTINATION IP ADDRESS ARRAY
  24. *
  25. * EXIT SOCKSTATUS = COMPLETION STATUS
  26. *
  27. * METHOD IF THE SOCKET HAS BEEN ABORTED BY NAM, RETURN AN
  28. * ABORT STATUS TO INFORM THE CALLER. IF THE SOCKET
  29. * IS NOT CONNECTED, RETURN AN ERROR STATUS. IF THE
  30. * APPLICATION BLOCK LIMIT HAS NOT BEEN REACHED, SET UP
  31. * THE UDP CALL BLOCK HEADER AND COPY THE CONTENTS OF
  32. * *BUFFER1* AND *BUFFER2* INTO THE DATA BLOCK AND SEND
  33. * THE BLOCK TO NAM.
  34. * IF THE APPLICATION BLOCK LIMIT HAS BEEN REACHED, CALL THE
  35. * NAM INPUT TRAFFIC HANDLER WAITING FOR THE OUTSTANDING
  36. * BLOCK COUNT TO FALL BELOW THE LIMIT OR FOR THE BLOCKING
  37. * WAIT TIMER TO EXPIRE.
  38. * IF NOT BLOCKING, CALL THE NAM INPUT TRAFFIC HANDLER
  39. * ONCE. IF THE DATA BLOCK CAN NOT BE SENT, SET THE STATUS
  40. * TO *FLOWCTRL* TO INDICATE THE BLOCK WAS NOT SENT.
  41. #
  42.  
  43. #
  44. **** PROC IPPSEND - XREF LIST
  45. #
  46. XREF
  47. BEGIN
  48. PROC IMNS; # MOVE NON-OVERLAPPING STRING #
  49. PROC IPINITH; # NAM INPUT TRAFFIC HANDLER #
  50. PROC NETPUT; # SEND OUTPUT BUFFER TO NETWORK #
  51. PROC RTIME; # REAL TIME CLOCK #
  52. PROC XDRBYTE; # CONVERT BYTES TO XDR FORMAT #
  53. PROC XDRINT; # CONVERT INTEGERS TO XDR FORMAT #
  54. END
  55. #
  56. **
  57. #
  58. ITEM SOCKID I; # SOCKET IDENTIFIER #
  59. ARRAY BUFFER1 [00:00] S(1);; # OUTPUT BUFFER TO SEND #
  60. ITEM BUFLEN1 U; # LENGTH OF DATA IN *BUFFER1* #
  61. ARRAY BUFFER2 [00:00] S(1);; # SECOND OUTPUT BUFFER TO SEND #
  62. ITEM BUFLEN2 U; # LENGTH OF DATA IN *BUFFER2* #
  63. ARRAY ADDRESS [00:00] S(1);; # SOURCE ADDRESS FOR DATA #
  64. ITEM SOCKSTATUS S:SOCKSTAT; # RETURNED SOCKET STATUS #
  65.  
  66.  
  67. ITEM BUFPOS U; # OFFSET IN *OUTBUF* #
  68. ITEM DESTBUF I; # CURRENT WRD LOCATION IN BUFFER#
  69. ITEM DESTPOS U; # BIT OFFSET IN BUFFER WORD #
  70. ITEM INDEX I; # LOOP COUNTER #
  71. ITEM LOOP I; # LOOP COUNTER #
  72. ITEM MOVEBITS U; # BITS TO MOVE TO *BUFFER* #
  73. ITEM SCRBUF U; # CURRENT LOCATION INP$BUF #
  74. ITEM SCRPOS U; # BIT OFFSET IN INP$BUF WORD #
  75. ITEM WAITLOOP I; # NUMBER OF WAIT CYCLES #
  76. ITEM WRITENUM I; # NUMBER OF XDR ITEMS TO WRITE #
  77. CONTROL EJECT;
  78. #
  79. **** START MAIN PROCEDURE
  80. #
  81.  
  82. IF (ACN$ABORT [SOCKID])
  83. THEN
  84. BEGIN # CONNECTION ABORTED #
  85. SOCKSTATUS = S"ABORT";
  86. RETURN;
  87. END
  88.  
  89. IF ACN$STATE [SOCKID] NQ S"BOUND"
  90. THEN
  91. BEGIN
  92. SOCKSTATUS = SOCKSTAT"INVALIDST";
  93. RETURN;
  94. END
  95.  
  96. IF (ACN$OBC [SOCKID] GQ ACN$ABL [SOCKID])
  97. THEN
  98. BEGIN # MAXIMUM OUTSTANDING BLOCK LMT #
  99. BLOCK = ACN$BLOCK [SOCKID]; # SET GLOBAL BLOCKING FLAG #
  100. IF BLOCK
  101. THEN
  102. BEGIN # WAIT FOR FC/ACK ON CONNECTION #
  103. WAITLOOP = ACN$WAITIME [SOCKID] / 2 + 1;
  104. RTIME (BWT$TIME); # CURRENT TIME #
  105. BWT$EXPIRE [0] = BWT$SECONDS [0] + ACN$WAITIME [SOCKID];
  106.  
  107. #
  108. **** CONTINUE POLLING THE NETWORK WAITING FOR FC/ACK SUPERVISORY
  109. * MESSAGES TO BE RECEIVED ON THE CONNECTION OR UNTIL THE WAIT TIMER
  110. * HAS EXPIRED. THE LOOP COUNTERIS SETTO THE WAIT TIME/2 DUE TO THE
  111. * NETWAIT TIME OF 2 SECONDS WHILE BLOCKING.
  112. #
  113.  
  114. FOR LOOP = 0
  115. WHILE (ACN$OBC [SOCKID] GQ ACN$ABL [SOCKID])
  116. DO
  117. BEGIN # WAIT FOR ACK OR EXPIRED TIME #
  118. FOR INDEX = 1 STEP 1
  119. WHILE (ACN$OBC [SOCKID] GQ ACN$ABL [SOCKID]) AND
  120. (NOT ACN$ABORT [SOCKID]) AND
  121. (INDEX LQ WAITLOOP)
  122. DO
  123. BEGIN
  124. IPINITH; # NAM INPUT TRAFFIC HANDLER #
  125. END
  126.  
  127. IF (ACN$ABORT [SOCKID])
  128. THEN
  129. BEGIN # CONNECTION ABORTED #
  130. SOCKSTATUS = S"ABORT";
  131. RETURN;
  132. END
  133.  
  134. IF (ACN$OBC [SOCKID] GQ ACN$ABL [SOCKID])
  135. THEN
  136. BEGIN # CHECK IF TIMED OUT #
  137. RTIME (BWT$TIME);
  138. IF (BWT$SECONDS [0] GQ BWT$EXPIRE [0])
  139. THEN
  140. BEGIN # TIMER EXPIRED #
  141. SOCKSTATUS = S"FLOWCTRL";
  142. RETURN;
  143. END
  144. ELSE
  145. BEGIN # TIME STILL TO WAIT #
  146. WAITLOOP = (BWT$EXPIRE [0] -
  147. BWT$SECONDS [0]) / 2 + 1;
  148. END
  149. END # CHECK IF TIMED OUT #
  150. END # WAIT FOR ACK OR EXPIRED TIME #
  151. END # WAIT FOR FC/ACK ON CONNECTION #
  152. ELSE
  153. BEGIN # NO ACK/NOT BLOCKING #
  154. IPINITH; # NAM INPUT TRAFFIC HANDLER #
  155.  
  156. IF (ACN$ABORT [SOCKID])
  157. THEN
  158. BEGIN # CONNECTION ABORTED #
  159. SOCKSTATUS = S"ABORT";
  160. RETURN;
  161. END
  162.  
  163. IF (ACN$OBC [SOCKID] GQ ACN$ABL [SOCKID])
  164. THEN
  165. BEGIN
  166. SOCKSTATUS = S"FLOWCTRL";
  167. RETURN;
  168. END
  169. END # NO ACK/NOT BLOCKING #
  170. END # DATA NOT AVAILABLE #
  171.  
  172. #
  173. **** DATA CAN BE SENT. PLACE THE UDP CALL HEADER INTO *OUTBUF*. THE
  174. * REQUEST CONSISTS OF THE CALL TYPE, UDP VERSION, AND FOUR 32 BIT
  175. * INTEGER ADDRESS. FOLLOWING THE ADDRESS THE CONTENTS OF *BUFFER*
  176. * ARE MOVED INTO *OUTBUF*. IF THE BLOCK TO BE TRANSMITTED IS
  177. * GREATER THAN *INPSIZE$* THEN AN ERROR STATUS IS RETURNED.
  178. #
  179.  
  180. BUFPOS = 0; # INITIALIZE BUFFER POSITION #
  181. P<IP$ADDR$REC> = LOC (ADDRESS);
  182. UDP$HEADER [0] = DESTREQ$;
  183.  
  184. WRITENUM = 2;
  185. XDRBYTE (OUTBUF, BUFPOS, UDP$HEAD$REC, WRITENUM, XDROPER"WRITE");
  186.  
  187. WRITENUM = 4;
  188. XDRINT (OUTBUF, BUFPOS, IP$ADDR$REC, WRITENUM, XDROPER"WRITE");
  189.  
  190. P<ABH> = LOC (DABH); # BASE ABH POINTER #
  191. ABHTLC [0] = BUFPOS + BUFLEN1 + BUFLEN2;# STORE LENGTH IN BYTES #
  192.  
  193. IF ((ABHTLC [0] * 2) / 15) GR INPSIZE$
  194. THEN
  195. BEGIN # *OUTBUF* TOO SMALL FOR DATA #
  196. SOCKSTATUS = S"REQFAIL";
  197. RETURN;
  198. END # *OUTBUF* TOO SMALL FOR DATA #
  199.  
  200. IF BUFLEN1 GR 0
  201. THEN
  202. BEGIN
  203. MOVEBITS = BUFLEN1 * 8;
  204. DESTBUF = LOC (OUTBUF) + (BUFPOS * 2) / 15;
  205. DESTPOS = XDRMODU ((BUFPOS * 8), 60);# WORD BIT OFFSET #
  206. SCRBUF = LOC (BUFFER1);
  207. SCRPOS = 0;
  208. IMNS (MOVEBITS, SCRBUF, SCRPOS, DESTBUF, DESTPOS);
  209.  
  210. IF BUFLEN2 GR 0
  211. THEN
  212. BEGIN
  213. SCRBUF = LOC (BUFFER2);
  214. SCRPOS = 0;
  215. MOVEBITS = BUFLEN2 * 8;
  216. IMNS (MOVEBITS, SCRBUF, SCRPOS, DESTBUF, DESTPOS);
  217. END
  218. END
  219.  
  220. ABHADR [0] = SOCKID; # STORE CONNECTION NUMBER #
  221. ABHABN [0] = ACN$ABN [SOCKID]; # STORE APPLICATION BLOCK NUMBER#
  222. ACN$ABN [SOCKID] = ACN$ABN [SOCKID] + 1;
  223. ACN$OBC [SOCKID] = ACN$OBC [SOCKID] + 1;
  224. NETPUT (DABH, OUTBUF); # SEND THE REQUEST #
  225.  
  226. SOCKSTATUS = S"OK";
  227.  
  228. RETURN; # RETURN TO CALLER #
  229.  
  230. END # IPPSEND #
  231.  
  232. TERM
cdc/nos2.source/nam5871/ippsend.txt ยท Last modified: 2023/08/05 17:22 by Site Administrator