Please enable JavaScript to view this site.

A-Shell Consolidated Reference

Navigation: Subroutines > MIAMEX

MX_FILESOCK

Scroll Prev Top Next More

Added October 2016

xcall MIAMEX, MX_FILESOCK, ch, socket, status

MX_FILESOCK (MIAMEX 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.

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 TCPXxs.

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 fnfilesock.bsi in SOSLIB:[907,10] for details.

History

2016 September, A-Shell 6.3.1524:  Routine added to A-Shell