Commit | Line | Data |
4536f655 |
1 | Stem::Socket Design Notes |
2 | |
3 | The Stem::Socket module provides an interface to create connected |
4 | sockets. It can either connect to a remote socket as a client or listen |
5 | for connections as a server. Its constructor takes an owner object, an |
6 | optional host or IP address and a required port number. Also a boolean |
7 | flag designates whether is it a client or server. If no host argument is |
8 | provided, it will default to localhost. To make a server listen on any |
9 | IP address (with the wild card INADDR_ANY), pass in the empty string '' |
10 | as the host. |
11 | |
12 | When a socket connection is made (either a client or a server), the |
13 | owner object is notified by a callback and the handle of the newly |
14 | created socket is passed to it. Since a client socket can timeout when |
15 | connecting to a server, a timeout value can be set. If the connection |
16 | request times out a different method is used as the callback to the |
17 | owner object. |
18 | |
19 | This module is only used internally and should not be configured. |