Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Pharo Smalltalk TCP Server
"Adapted from
$! denotes the end of a message
| connectionSock interactSock request stream |
connectionSock := Socket newTCP.
connectionSock listenOn: 8888 backlogSize: 10.
interactSock := connectionSock waitForAcceptFor: 15.
stream := SocketStream on: interactSock.
request := stream upTo: $!.
stream sendCommand: 'Pharo Server: ', request, ' received!'.
Transcript cr; show: request.
] ensure: [
connectionSock closeAndDestroy.
stream close ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment