"Filed out from GNU Smalltalk version 2.2b on 26-Oct-2006 10:30:02"! Smalltalk.Object subclass: #SocketTest instanceVariableNames: 'buffer socket ' classVariableNames: '' poolDictionaries: '' category: nil! SocketTest comment: nil! !SocketTest class methodsFor: 'instance creation'! new | n | n := super new. n init. ^n ! ! !SocketTest methodsFor: 'basic'! handle: sock [ [ [ sock atEnd ] whileFalse: [ buffer := buffer, (sock nextHunk). sock nextPutAll: '['. sock nl. sock nextPutAll: buffer. sock nl. sock nextPutAll: ']'. sock nl. sock flush ]. ] ensure: [ sock close ] ] fork ! init buffer := String new ! start 'Starting server...' displayNl. socket := TCP.ServerSocket port: 12345. socket isNil ifTrue: [ self error: 'couldn''t create ServerSocket!' ]. [ socket waitForConnection. 'Got connection!' displayNl. self handle: (socket accept) ] repeat ! stop socket close ! !