Please enable JavaScript to view this site.

A-Shell Development History

New MIAMEX function: MX_FILESOCK (187) binds a TCP socket to a sequential file channel so that PRINT #CH and/or INPUT #CH transfers data over the socket rather than to/from the file.

xcall MIAMEX, MX_FILESOCK, ch, socket, status

Parameters

ch  (num)  [in]

must be a file channel (> 0) open for sequential input or output. Typically you would open the file using the .NULL filespec as described in the previous edit note.

socket  (num)  [in]

must be a valid socket opened via TCPX.SBR.

status  (signed num)  [out]

returns 0 for success, else error.

If ch was open for output, then after the successful completion of the MX_FILESOCK call, PRINT #CH statements will output to the socket instead of the file. Similarly, if ch was open for input, then INPUT #ch statements will read from the socket.

Note that while sockets are bidirectional, sequential file channels are not, so if you want to both input and output to the socket this way, you'll need to open two file channels and bind them both to the same socket with two separate MX_FILESOCK calls.

Once the file channel is bound to the socket, closing the file channel will also close the socket.

To simplify the operation of opening the file and socket and binding the two together, a pair of functions has been added to the SOSFUNC: library:

Fn'FileSock'Out(ch, socket, server$)

Fn'FileSock'In(ch, socket, server$)

 

See the fnfilesock.bsi source code in the [907,10] directory of the SOSLIB for details, including a sample/test routine.