"Filed out from GNU Smalltalk version 2.2b on 31-Oct-2006 12:27:04"! PackageLoader fileInPackage: #TCP! Object subclass: #Communicator instanceVariableNames: 'host port thread buffer ' classVariableNames: '' poolDictionaries: '' category: nil! Communicator comment: 'This is the main Communicator class, it handles a connection with a communicator server which serves as a gateway to multiple chat and instant messaging services.'! !Communicator class methodsFor: 'instance creation' copy! new: host port: port ^(self basicNew) host: host; port: port; initialize ! ! !Communicator methodsFor: 'initialization' copy! host: nHost ^host := nHost! port: nPort ^port := nPort! initialize | socket | ('started communicator on ', host, ':', (port printString)) displayNl. socket := TCP.Socket remote: host port: port. socket isNil ifTrue: [ ^self error: 'couldn''t create socket!' ]. socket nextPutAll: 'Hello!'. socket nl. socket flush. thread := [ [ socket isPeerAlive ] whileTrue: [ | hunk | hunk := socket nextHunk. ('read hunk [', hunk, ']') displayNl. ]. 'End!' displayNl ] fork ! ! Smalltalk at: #x put: (Communicator new: 'localhost' port: 1234)! [ Processor yield ] repeat!