Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
BroadcastCommunity.qnx.com will be offline from May 31 6:00pm until June 2 12:00AM for upcoming system upgrades. For more information please go to https://community.qnx.com/sf/discussion/do/listPosts/projects.bazaar/discussion.bazaar.topc28418
Forum Topic - getsockopt() and the optval parameter: (2 Items)
   
getsockopt() and the optval parameter  
Hi all,

I am using the getsockopt() API in QNX, 

getsockopt(socket,
            level,
            optName,
            (void *)optVal,
            (socklen_t *)optLen),

, using these parameters:

getsockopt(clientSocket,
            SOL_SOCKET,
            SO_KEEPALIVE,
            &socketOption,
            &socketOptionLen);

The socketOption is just an 32-bit integer, and I expect it to be just a pointer to the value of SO_KEEPALIVE. If I 
print it as a decimal, with %d, I get an "8". Depending on the option, this value changes, form "8", to "0", to "22528",
 depending on the option that I use. Where can I find documentation about what to expect on the socketOption?

I want to write code that after making this call verifues that the option was properly set. Right now, I have smth like 
"assert(socketOption==TRUE)", but this is not working properly.

Thanks for the insights,
temax.
Re: getsockopt() and the optval parameter  
On Fri, Dec 26, 2014 at 11:33:57AM -0500, Victor Gomez wrote:
> Hi all,
> 
> I am using the getsockopt() API in QNX, 
> 
> getsockopt(socket,
>             level,
>             optName,
>             (void *)optVal,
>             (socklen_t *)optLen),
> 
> , using these parameters:
> 
> getsockopt(clientSocket,
>             SOL_SOCKET,
>             SO_KEEPALIVE,
>             &socketOption,
>             &socketOptionLen);
> 
> The socketOption is just an 32-bit integer, and I expect it to be just a pointer to the value of SO_KEEPALIVE. If I 
print it as a decimal, with %d, I get an "8". Depending on the option, this value changes, form "8", to "0", to "22528",
 depending on the option that I use. Where can I find documentation about what to expect on the socketOption?
> 
> I want to write code that after making this call verifues that the option was properly set. Right now, I have smth 
like "assert(socketOption==TRUE)", but this is not working properly.

For the ones that are simple enable / disable:

SO_USELOOPBACK:
SO_DONTROUTE:
SO_DEBUG:
SO_KEEPALIVE:
SO_REUSEADDR:
SO_REUSEPORT:
SO_BROADCAST:
SO_OOBINLINE:
SO_TIMESTAMP:
SO_ACCEPTCONN:

The optval will be 0 if not set and non zero if set.