Go to the first, previous, next, last section, table of contents.


Class Socket

Internally, Class Socket implements Muq's network interface logic: all the good select(), bind(), listen() and so forth code lives there, with attendant portability headaches.

To the muf programmer, Muq attempts to make an Socket look like just one more job that communicates via message streams, but with the mysterious restriction that only Strings may be passed to/from it (since the network is bytestream-oriented, and the program on the far end normally is also).

Class Socket adds the following properties to those of Class Plain:

$S.closedBy:       NIL, else one of :close :exit :signal.
$S.exitStatus:     NIL, else integer which subprocess gave [_]exit();
$S.lastSignal:     NIL, else integer signal which killed subprocess.
$S.fdToRead:      Integer file descriptor used for read()s  (else NIL).
$S.fdToWrite:     Integer file descriptor used for write()s (else NIL).
$S.nlToNetCrnl:  T to convert \n -> \r\n on output, else NIL.
$S.netCrnlToNl:  T to convert \r\n -> \n on input,  else NIL.
$S.killStandardOutputOnExit: Set $S.standardOutput$S.dead at shutdown?
$S.passNonprintingFromNet NIL to change nonprinting chars to blanks else T.
$S.passNonprintingToNet NIL to strip all but isprint() and \n chars else T.
$S.inputByLines   T return only complete lines where practical else NIL.
$S.standardInput:  MessageStream whose contents should be fed to network.
$S.standardOutput: MessageStream to which network bytes should be sent.
$S.outOfBandInput:  MessageStream to send as network TELNET commands &tc.
$S.outOfBandOutput: MessageStream to get network TELNET commands &tc.
$S.thisTelnetState: 256 byte-string with 256 telnet option states.
$S.thatTelnetState: 256 byte-string with 256 telnet option states.
$S.telnetProtocol: T to support TELNET protocol on net, else NIL.
$S.telnetOptionHandler: NIL else vector of 256 compiled-functions.
$S.telnetOptionLock: NIL else a lock instance protecting *-telnet-state.
$S.outOfBandJob: Job doing telnet &tc processing for socket, else NIL.
$S.discardNetboundData: Set T to suppress output. Reset by any data read from net.
$S.session:         Session to recieve hangup signals and such for this socket.
$S.thisPort:       Integer port number of near end of connection, else zero.
$S.thatPort:       Integer port number of far  end of connection, else zero.
$S.thatPid:        Integer process ID for $S.type == :popen sockets, else NIL.
$S.thatAddress:    "128.95.44.22" adr for far  end of connection, else "".
$S.ip0:             1st (128) byte of above, as an integer.
$S.ip1:             2nd ( 95) byte of above, as an integer.
$S.ip2:             3rd ( 44) byte of above, as an integer.
$S.ip3:             4th ( 22) byte of above, as an integer.
$S.type:            Type of associated socket: stream (:tcp) vs
		    console (:tty) vs batch-file (:bat) vs dead (:eof)...
$S.outdrainMilliseconds These five properties implement timeouts used
$S.eofwaitMilliseconds  internally by the implementation when closing
$S.hupwaitMilliseconds  down a socket.  I don't know why you'd need to
$S.killwaitMilliseconds fiddle with them, but if you do, see the comments
$S.indrainMilliseconds  and transition diagram in the muq/c/skt.t file.

Note: For convenience, the $S properties are also available in the public (default) propdir.

You must own the socket, or be root running OMNIPOTENT, to read $S.fdToRead, $S.fdToRead, $S.thisPort, $S.thatPort, or $S.thatAddress.

Possible values for $S.type are:

:batch
Socket reading batch-mode from a list of host files.
:tty
Socket representing a unix-level terminal (originating console).
:tcp
Socket representing a TCP/IP byte-stream network connection.
:udp
Socket representing a UDP datagram network socket.
:ear
Socket listening for new connections.
:popen
Socket connected via pipe(s) to a popen()'d host process.
:eof
Socket which has been closed (or never opened).

The TELNET processing triggered by setting socket$S.telnetProtocol to T collapses 0xFF 0xFF bytepairs from the net to single 0xFF bytes and does the reverse when sending to the net. In addition, TELNET protocol commands recieved from the net (marked by an 0xFF byte followed by something other than a second 0xFF byte) are sent to the socket$S.outOfBandOutput stream instead of the socket$S.standardOutput (if socket$S.outOfBandOutput is set to a stream) and any text written to the socket$S.outOfBandInput stream is merged into the output bytestream.

See section ]listenOnSocket. See section makeSocket. See section ]openSocket. See section ]closeSocket.


Go to the first, previous, next, last section, table of contents.