Improve this page Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using local clone. Page wiki View or edit the community-maintained wiki page associated with this page.


Warning: This module is considered out-dated and not up to Phobos' current standards. It will remain until we have a suitable replacement, but be aware that it will not remain long term.

SocketStream is a stream for a blocking, connected Socket.

See /dmd/samples/d/htmlget.d

Christopher E. Miller



class SocketStream:;
SocketStream is a stream for a blocking, connected Socket.

this(Socket sock, FileMode mode);
Constructs a SocketStream with the specified Socket and FileMode flags.

this(Socket sock);
Uses mode FileMode.In | FileMode.Out.

Socket socket();
Property to get the Socket that is being streamed.

size_t readBlock(void* _buffer, size_t size);
Attempts to read the entire block, waiting if necessary.

size_t writeBlock(const void* _buffer, size_t size);
Attempts to write the entire block, waiting if necessary.

ulong seek(long offset, SeekPos whence);
Socket streams do not support seeking. This disabled method throws a SeekException.

string toString();
Does not return the entire stream because that would require the remote connection to be closed.

void close();
Close the Socket.