I found some example code for SO_LINGER in JforC, but I don't know if it is 
outdated, or does not work for osx:

first the exact example:

sdcheck_jsocket_ sdsetsockopt 0, SOL_SOCKET_jsocket_,SO_LINGER_jsocket_, 1 66

fails due to length error 5 params for 4 expected.

but other attempts also fail including:
sdcheck_jsocket_ sdsetsockopt_jsocket_ 0, 
SOL_SOCKET_jsocket_,SO_LINGER_jsocket_, 1

sdcheck_jsocket_ sdsetsockopt_jsocket_ 0, 
SOL_SOCKET_jsocket_,SO_LINGER_jsocket_, 0


The latter corresponds to the value of sdgetsockopt.

There is exception handling code for SO_LINGER in set and get sockopt.  Is the 
issue I am having osx specific?

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
)



there i


----- Original Message -----
From: Pascal Jasmin <[email protected]>
To: "[email protected]" <[email protected]>
Cc: 
Sent: Monday, March 10, 2014 3:30:53 PM
Subject: Re: [Jprogramming] sdcleanup_jsocket_ on osx

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
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to