| | 231 | # sugar over starting a TCP server. |
|---|
| | 232 | # INCOMPLETE, will throw a bunch of different socket-library |
|---|
| | 233 | # errors (DNS, no-bind, etc) which we ought to wrap and |
|---|
| | 234 | # either re-raise, or generate events for. |
|---|
| | 235 | # INCOMPLETE, need to similarly sugar creation of Unix-domain sockets. |
|---|
| | 236 | # Either a different method, or observe the params: for unix |
|---|
| | 237 | # only a filename is needed. |
|---|
| | 238 | # Of course we'll also need named pipes and whatever that Windows |
|---|
| | 239 | # near-equivalent is called. |
|---|
| | 240 | # RETURNS: the newly-created eventable-io object, so the caller |
|---|
| | 241 | # can add handlers, etc. |
|---|
| | 242 | # |
|---|
| | 243 | def self.start_server host, port |
|---|
| | 244 | sd = Socket.new( Socket::AF_INET, Socket::SOCK_STREAM, 0 ) |
|---|
| | 245 | sd.bind( Socket.pack_sockaddr_in( port, host )) |
|---|
| | 246 | sd.listen( 50 ) # 5 is what you see in all the books. Ain't enough. |
|---|
| | 247 | TcpServerEventableIO.new sd |
|---|
| | 248 | end |
|---|
| | 249 | |
|---|
| | 250 | #-- |
|---|