MzScheme provides a minimal collection of TCP-based communication procedures.
The return value of tcp-listen is a TCP listener value. This value can be used in future calls to tcp-accept, tcp-accept-ready?, and tcp-close. Each new TCP listener value is placed into the management of the current custodian (see section 9.5).
If the server cannot be started by tcp-listen, the exn:i/o:tcp:listen exception is raised.
Two values (see Chapter 2) are returned by tcp-connect: an input port and an output port. Data can be received from the server through the input port and sent to the server through the output port. If the server is a MzScheme process, it can obtain ports to communicate to the client with tcp-accept. These ports are placed into the management of the current custodian (see section 9.5).
The client input and output ports are not independent: closing the output port does not cause the server to receive an end-of-file. Instead, both ports must be closed before the server receieves an end-of-file.
If a connection cannot be established by tcp-connect, the exn:i/o:tcp:connect exception is raised.
Two values (see Chapter 2) are returned by tcp-accept: an input port and an output port. Data can be received from the client through the input port and sent to the client through the output port. These ports are placed into the management of the current custodian (see section 9.5).
The accepted input and output ports are not independent: closing the output port does not cause the client's input port to receive and end-of-file. Instead, both ports must be closed before the client receieves an end-of-file.
If a connection cannot be accepted by tcp-accept, the exn:i/o:tcp:accept exception is raised. If the listener has been closed, the exn:i/o:tcp:listener-closed exception is raised.
If the listener has been closed, the exn:i/o:tcp:listener-closed exception is raised.
If the listener has already been closed, the exn:i/o:tcp:listener-closed exception is raised.
This procedure is provided because MzScheme automatically buffers data written to a TCP output port. Stream-based applications can use this procedure to detect excessive output buffering.