Serving static files from Comanche Re: [Seaside] listen on a single ip

Sean Allen sean at monkeysnatchbanana.com
Tue Apr 20 14:11:54 UTC 2010


A Matter of style.

Related to the listener adapter.

Swazoo uses '*' to indicate all interfaces. I originally coded for
that. Should I keep that as the 'all interfaces'?
It results in the swazoo code not needing special logic but any other
adapters might. Case in point, the listener
adapter. Its a different method call if you want to listen on all vs
just 1. Highlighted below in between the -----'s
is what would be in the listener adapter. Not sure how the core team
feels about code like this. I don't honestly see
much of a better way as this is isolated to one spot in one method.

listenLoop
	| socket |
	socket := Socket newTCP.
----
	ip = '*' ifTrue: [
		socket
			listenOn: port
			backlogSize: 50.
	]
	ifFalse: [
		socket
			listenOn: port
			backlogSize: 50
			interface: ip asIpByteArray asSocketAddress.
	].
----
	socket isValid ifFalse: [ self error: 'Cannot listen on interface ',
ip greaseString,' port ' , port greaseString ].
	
	[
	[ socket isValid ifFalse: [ ^ self listenLoop ].
	self waitForConnection: socket ] repeat ] ifCurtailed:
		[ (Delay forMilliseconds: 10) wait.
		socket destroy ]

I could move the backlogSize out so the 50 is harcoded as a magic
number in two points but other than that,
without getting overly complicated, I can't think of a better way to address.


On Tue, Apr 20, 2010 at 3:53 AM, Julian Fitzell <jfitzell at gmail.com> wrote:
> Hi Sean,
>
> Not sure... I guess we either put the instVar on the abstract ServerAdaptor
> and ignore it on subclasses that don't support it or you just implement it
> on the Swazoo adaptor and we pull it up whenever we're ready to implement it
> elsewhere. I don't think it matters too much, so just do what's easiest. If
> the ListenerAdaptor is using HTTP internals direectly enough that it's easy,
> that would be a good reason to pull it up.
>
> If you feel like chasing up Göran/Giovanni to see about extending Comanche
> to support it, though, that would be awesome!
>
> And, yes, it would be nice to have support for it in the control panel if
> you don't mind. Just default to 0.0.0.0 on creation and add a command to
> change it I guess?
>
> Julian
>
> On Tue, Apr 20, 2010 at 2:24 AM, Sean Allen <sean at monkeysnatchbanana.com>
> wrote:
>>
>> Julian,
>>
>> I did this for Swazoo. It was 5 minutes of work.
>> I haven't done for Comanche yet, wanted to get some feedback first.
>>
>> The Comanche adapter uses HTTPService which descends from TcpService
>> to register itself.
>> TcpService has the ability in theory to do ip and port because of this
>> instance side method:
>>
>> initializeOnPort:address:priority:
>>
>> However, nowhere else in the comanche code can i see it ever using the
>> priority or address anywhere.
>> >From what I can see, its incomplete and only capable at this time of
>> doing by port. The Comanche code is
>> obviously outside the scope of seaside so I'm not sure how to proceed.
>>
>> Should I only implement for Swazoo ( done ) and call it a day or
>> should I talk to Goran about adding the required functionality
>> to Comanche and hold back the changes til then.
>>
>> Additionally, should I an additional popup when configuring an adaptor
>> via the control panel so that it prompts for port and ip or should
>> i leave this as functionality you can get at if you don't use the
>> control panel? I need this for running on Gemstone
>> so control panel isn't an issue for me, but I can add if its desired.
>>
>> Last but not least, the listener adapter, add functionality to it as
>> well? ( I haven't looked at it yet in anything other than a cursory
>> fashion ).
>> And the test adapter, not needed for that correct?
>>
>> -Sean-
>>
>>
>>
>> On Tue, Mar 30, 2010 at 4:08 AM, Julian Fitzell <jfitzell at gmail.com>
>> wrote:
>> > On Tue, Mar 30, 2010 at 1:44 AM, Sean Allen
>> > <sean at monkeysnatchbanana.com> wrote:
>> >> On Mon, Mar 29, 2010 at 7:06 PM, Julian Fitzell <jfitzell at gmail.com>
>> >> wrote:
>> >>> Ok, fair enough. And yes we should add it. (isn't there an issue open
>> >>> for that somewhere?)
>> >>>
>> >>
>> >> I dont think so,
>> >
>> > Here it is:
>> >
>> > http://code.google.com/p/seaside/issues/detail?id=360
>> >
>> >>> The question I guess is how should you specify the interface? Is an IP
>> >>> string good enough?
>> >>>
>> >>
>> >> Yes.
>> >>
>> >> I already did the work for the Swazoo adapter.
>> >> I'll take on the work of doing that and the others.
>> >> Its my itch, I'll scratch it.
>> >>
>> >> Should I do for 2.8 and 3.0 or just 3.0?
>> >>
>> >> Is the best thing to do:
>> >>
>> >> create an issue.
>> >> attached .mcz files to the issue
>> >
>> > Sure, or upload to:
>> >
>> > MCHttpRepository
>> >    location: 'http://www.squeaksource.com/SeasideInbox'
>> >    user: ''
>> >    password: ''
>> >
>> > Julian
>> > _______________________________________________
>> > seaside mailing list
>> > seaside at lists.squeakfoundation.org
>> > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>> >
>> _______________________________________________
>> seaside mailing list
>> seaside at lists.squeakfoundation.org
>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
>
> _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
>


More information about the seaside mailing list