|
Hi,
I am attempting a port of SoapOpera to GemStone and have made good
progress. The one problem I'm having with a port of the Soap client is
the way that HTTPSocket was ported to GemStone. In essence the problem
is that in Pharo, HTTPSocket is part of the Network-Protocols category
and subclasses from Socket. This binds the interface of HTTPSocket
quite closely to the Squeak Socket.
In our porting attempt, we thought it a great idea to use SpSocket.
But the class HTTPSocket in the Squeak package subclasses from
SpSocket, which gives HTTPSocket in GemStone a quite different
interface.
My question essentially is what is the right strategy to follow as
SoapOpera (and I guess a few others) uses HTTPSocket, but the Squeak
interface inherited from Socket. The goal I think is to get the
interface compatible in GemStone.
To get it working, I added methods to SpSocket (in Pharo and GemStone)
and also added some odds and ends on either side. Is it OK to extend
sport to implement more of the Squeak Socket interface? It did not
feel like the right solution, although the additional methods appear
to be harmless. Here they are:
!SpSocket methodsFor: 'services-status' stamp: 'OttoBehrens 2/21/2011 10:12'!
closeAndDestroy
^ self close! !
!SpSocket methodsFor: 'services-status' stamp: 'OttoBehrens 2/21/2011 10:30'!
connectTo: hostAddress port: port
^ self connectTo: (SpIPAddress host: hostAddress port: port)! !
!SpSocket methodsFor: 'testing' stamp: 'OttoBehrens 2/21/2011 10:53'!
isConnected
^ self underlyingSocket isConnected! !
!SpSocket methodsFor: 'sending' stamp: 'OttoBehrens 2/21/2011 10:24'!
sendData: sourceByteArray
^ self write: sourceByteArray! !
!SpIPAddress class methodsFor: 'instance creation' stamp: 'OttoBehrens
2/21/2011 09:34'!
hostName: aHostNameString port: aPortNumber
"^a SpSocketAddress
I translate aHostNameString to an IP address and then create
a new instance of myself with >>host:port:"
^ self host: (self ipAddressForHostName: aHostNameString timeout: 60)
port: aPortNumber! !
!SpIPAddress class methodsFor: 'instance creation' stamp: 'OttoBehrens
2/21/2011 09:34'!
ipAddressForHostName: aHostNameString timeout: aTimeout
^ NetNameResolver addressForName: aHostNameString timeout: aTimeout! !
|