Skip to content

Most primitive TCPServer which responsible for managing server socket connection loop

License

Notifications You must be signed in to change notification settings

pharo-ide/TCPServer

Repository files navigation

TCPServer

GitHub release Unit Tests

Pharo 7.0 Pharo 8.0 Pharo 9.0 Pharo 10 Pharo 11

It is a most primitive TCP server.

It implements classic incoming connections loop running in background process.

Users should subclass TCPServer and implement method #processNewConnection:.

To start a server simply create an instance and ask it to #start:

server := TCPServerSubclass new.
server start.

It will run a listener socket and an incoming connections loop.

By default it allows OS to assign free port for the server (using zero port number):

server := TCPServerSubclass new.
server port. "==> 0"
server start.
server port > 0 "==> true"

But users can specify concrete port using #on: message:

server := TCPServerSubclass on: 40422

If given port is busy the #start message will signal an error.

To stop the server use #stop message:

server stop.

It will close listener socket and terminate incoming connections loop.

I maintain the list of all running servers on my class side variable #RunningServers:

TCPServer runningServers

Installation

Metacello new
  baseline: 'TCPServer';
  repository: 'github://pharo-ide/TCPServer';
  load

Use following snippet for stable dependency in your project baseline:

spec
    baseline: 'TCPServer'
    with: [ spec repository: 'github://pharo-ide/TCPServer:v1.0.1' ]

About

Most primitive TCPServer which responsible for managing server socket connection loop

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published