Skip to content
This repository was archived by the owner on Jan 16, 2019. It is now read-only.

Sockets

Frank Kleine edited this page Aug 3, 2014 · 3 revisions

Socket operations

Socket operations can be done using stubbles\peer\Socket. A socket can be created by supplying the host to the constructor, and optionally a port. If no port is specified it will fall back to port 80.

On construction only the socket instance is created. To actually open the connection the connect() method must be called. Optionally a time-out for establishing the connection can be supplied, if none given its 2 seconds.

The instance provides methods to read from and write to the socket. In case this is not comfortable enough the in() and out() methods wrap the socket into a stream which then can be used to read or write.

Clone this wiki locally