ยค asyncTransmitterF, asyncTransceiverF

Sockets

Types

asyncTransmitterF :: Socket -> F String b
asyncTransceiverF :: Socket -> F String String

Synopsis

asyncTransmitterF socket

Description

asyncTransmitterF is an asynchronous version of transmitterF.

Since the current fudget library implementation is sequential and deterministic, the synchronous write operations used by transmitterF may block the entire program. For programs that write large amount of data to a slow consumer, e.g., a program that outputs to the audio device, this might be a problem.

asyncTransmitterF uses asynchronous writes and thus never blocks the program. On the other hand, it might have to buffer large amounts of data, since there is no flow control between asyncTransmitterF and the fudget that produces the data. A producer like numbersSP 0 where

  numbersSP n = putSP (show n) (numberSP (n+1))

will cause the program to run out of memory sooner or later (probably sooner). But there is no limit on the size of a single message, as long as it is produced lazily, so a producer like

  putSP (show [1..]) nullSP

will work fine.

Input

Strings to be sent to the peer. An empty string indicates the end of the stream and causes the socket to be closed (but not until all data in the buffer has been sent).

Output

asyncTransceiverF: Strings received from the peer. An empty string indicates the end of the stream and means that the peer has closed the connection. asyncTransmitterF: no output is produced.

Arguments

socket :: Socket
The socket to communicate with.

Example

 openFileAsSocketF "/dev/audio" "w" asyncTransmitterF

See Also

The corresponing fudgets with syncronous write: transmitterF, transceiverF.

Bugs

This page documents work progress. Information on this page is subject to change without notice and does not represent a commitment on the part of the Fudgets corporation.

There is no way to discard data in the buffer.