Reconnectable Sockets?

Ken Causey ken at
Tue Apr 23 21:07:39 UTC 2002

Yes, it's me again.

Is it the intention that that Socket and it's children be
reconnectable?  In other words, should I be able to close a connected
socket and at some point in the immediate future connectTo:port: again?
on the same instance?  This doesn't seem to be working.

As everyone on the list knows by now I've been working with POPSocket. 
I've modified it slightly to support disconnection without destroying
the socket.  The changeset is attached for reference purposes.  When
primSocket:connectTo:port: is called on such a "closed" socket, it
returns an unconnected socket.

Is this correct behaviour?  It doesn't sound appropriate to me.

Ken Causey

-------------- next part --------------
'From Squeak3.2gamma of 15 January 2002 [latest update: #4827] on 23 April 2002 at 3:31:43 pm'!

!POPSocket methodsFor: 'low-level protocol' stamp: 'KLC 4/16/2002 14:20'!
	"disconnect, then destroy the socketHandle"

	self isValid ifFalse: [^ self].  "already destroyed"
	self disconnectFromPOPOnly.
	self reportToObservers: 'destroying socketHandle'.
	self closeAndDestroy
! !

!POPSocket methodsFor: 'low-level protocol' stamp: 'KLC 4/16/2002 14:20'!
	"Send a QUIT message, then disconnect, but DON'T destroy the socketHandle"

	self isValid ifFalse: [^self]. "already closed"
	self isConnected ifFalse: [^ self]. "socket is valid, but we aren't connected"
	self reportToObservers: 'closing connection, socket remains valid for reconnect'.
	numMessages _ nil.
	self sendCommand: 'QUIT'.
	self reportToObservers: self getResponse.
	self close! !

More information about the Squeak-dev mailing list