NB. =========================================================
NB. returns the value of a socket option
sdgetsockopt=: 3 : 0
's lev name'=. y
r=. getsockoptJ s;lev;name;(,_1);,4
if. 0~:res r do. 0;~sdsockerror'' return. end.
d=. ''$>4{r
if. name-:SO_LINGER do. 0;65536 65536#:d else. 0;d end.
)

NB. =========================================================
NB.*sdsetsockopt v sets the int value of a socket option.
sdsetsockopt=: 3 : 0
's lev name val'=. y
if. name -: SO_LINGER do. val=. 65536 65536#.val end.
rc0 setsockoptJ s;lev;name;(,val);4
)

so it seems that you need to encode your val for SO_LINGER
before calling sdsetsockopt.

Пн, 10 мар 2014, Pascal Jasmin писал(а):
> thank you for pointing this out.
> 
> While trying to make a reset verb, I can't seem to set this option:
> 
> cocurrent 'jsocket'
> 
> sdreset =: 3 : 0
> pD v=. sdcheck sdgetsockopt 0; SOL_SOCKET_jsocket_;SO_LINGER_jsocket_
> pD sdcheck sdsetsockopt 0;SOL_SOCKET_jsocket_;SO_LINGER_jsocket_;  1 0
> pD sdcleanup_jsocket_ ''
> pD sdsetsockopt 0;SOL_SOCKET_jsocket_;SO_LINGER_jsocket_; v
> )
> 
> 
> The first line returns ,< 0 0
> 
> its not clear how to pass the shape component in the 2nd line, but at any 
> rate, I generate EINVAL errors no matter what I try to pass in set option, 
> including 0 0 or ,< 0 0.
> 
> Could you please help in how to call sdsetsockopt for SO_LINGER?
> 
> ----- Original Message -----
> From: bill lam <[email protected]>
> To: [email protected]
> Cc: 
> Sent: Monday, March 10, 2014 10:57:56 AM
> Subject: Re: [Jprogramming] sdcleanup_jsocket_ on osx
> 
> This is socket linger timeout, a feature not a bug. you may set tcp option
> to disable it but I guess it is there for a good reason.
> On Mar 10, 2014 10:51 PM, "Pascal Jasmin" <[email protected]> wrote:
> 
> > actually, an idle loop doesn't always free up resources.  Though load
> > 'socket' seems to reset it.
> >
> >
> > ----- Original Message -----
> > From: Pascal Jasmin <[email protected]>
> > To: "[email protected]" <[email protected]>
> > Cc:
> > Sent: Monday, March 10, 2014 10:31:53 AM
> > Subject: [Jprogramming] sdcleanup_jsocket_ on osx
> >
> > sdcleanup_jsocket_ '' on windows will close all sockets correctly.  On
> > OSX, it seems to require going to idle loop before any reuse of previous
> > sockets (listen) is done.
> >
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
> 
> >
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
> 
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm

-- 
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
gpg --keyserver subkeys.pgp.net --armor --export 4434BAB3
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to