Created
December 8, 2012 23:01
-
-
Save seandenigris/4242432 to your computer and use it in GitHub Desktop.
Pharo Smalltalk TCP Server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"Adapted from http://www.slideshare.net/nourybouraqadi/pharo-networking-by-example | |
$! 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