chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] Re: tcp-read-timeout: procedure or parameter?


From: Jim Ursetto
Subject: Re: [Chicken-users] Re: tcp-read-timeout: procedure or parameter?
Date: Tue, 24 Jun 2008 14:50:57 -0500

Hello,

Although unit tcp doesn't have an explicit API for setting socket options,
it is possible to do this for server sockets.  (IIRC it can't be done at
the moment for clients as that socket is not directly exposed to the user.)
Here is an example:

#;1> (use tcp socket)
; loading library tcp ...
; loading /usr/local/lib/chicken/3/socket.so ...
#;2> (define L (tcp-listen 8080))
#;3> (define S (tcp-listener-fileno L))
#;4> (socket-keep-alive S)
#f
#;5> (set! (socket-keep-alive S) #t)
#;6> (socket-keep-alive S)
#t

See http://chicken.wiki.br/socket and
http://chicken.wiki.br/socket#Disable%20Nagle's%20Algorithm%20on%20TCP%20listener%20socket

Now, this definitely works with TCP options, but I didn't verify the effect of
setting SO_ options yet.  It might not work properly because the TCP unit calls
both socket() and bind() [in ##net#bind-socket] before you get a chance to
set the socket options, and setting these options should probably happen
between those two calls.

My only suggestion there would be to add a parameter to the TCP unit,
say tcp-socket-setup, which would be called between socket() and bind()
for servers, or between socket() and connect() for clients.  It would
be a one argument procedure which would just receive a socket fileno.
Then you could do whatever you want with the fileno without jamming
lots of stuff into the TCP unit.

For example,

(use tcp socket)
(parameterize ((tcp-socket-setup (lambda (s)
                                   (set! (socket-keep-alive s) #t)
                                   (set! (tcp-no-delay s) #t))))
  (tcp-listen 8080))

On the other hand, some may prefer a more nicely integrated way to
set socket options.  Other ideas?

On 6/24/08, William Xu <address@hidden> wrote:
> "felix winkelmann" <address@hidden> writes:
>
>> A parameter is a special kind of procedure. You access it like this:
>>
>> (tcp-read-timeout) -> <timeout-value>
>> (tcp-read-timeout <new-value>)
>
> Ah, I didn't know this kind of procedure.  Thanks!
>
>> There is now API for that, yet. But see the function ##sys#bind-socket
>> in tcp.scm for an example of the use of socket options. I guess we
>> have to add support for this.
>
> That would be great.  :-)
>
> --
> William
>
> http://williamxu.net9.org
>
> There's no heavier burden than a great potential.
>
>
>
> _______________________________________________
> Chicken-users mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/chicken-users
>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]