select() problems...

<!doctype html public “-//w3c//dtd html 4.0 transitional//en”>

Ok this is my problem:

I have an application that is supposed to receive both QNX-messages and socket
connections at the same time which means that I have to make select() react
to both. This is done by using (the poorly documented) function _select_receive()
which when present is called automatically from within the normal select().

Here is some simplified a-little-bit-more-than-pseudo code that shows the problem:

pid_t _select_receive(pid_t proxy) {
    char buf[DEFAULT_RECV_SIZE];

    pid = Receive(0, buf, DEFAULT_RECV_SIZE );

    // The "documentation" says that this function is not
    // allowed to return until the proxy it was passed has been
    // triggered.
    while (pid != proxy){
        // Do stuff with the QNX-messages that was received.
        HandleQNXReceive(pid, buf, DEFAULT_RECV_SIZE);

        pid = Receive(0, buf, DEFAULT_RECV_SIZE );
    }

    return pid;
}
 

main()
{
    while(1){
        select(usual parameters);

        HandleSelectReturnStuff();

        // The select() above will only release for timeouts and regular file descriptor events
        // as usual. Not for QNX-messages. In the case where you only are using sockets,
        // one can write code that releases the select() and the event is taken care of. Depending
        // on the event, you might want to go into select() again with for instance a new timeout
        // or a new set of parameters. My problem now is that when an event comes in as a QNX-
        // message and I also then want to change the timeout lets say, how do I do that from
        // within the _select_receive() function? You see, when a QNX-message has been
        // handled, select() calls _select_receive() again internally, not letting my main program
        // do any actions.
    }
}
 

Looks like I wrote most of my question in that comment :slight_smile:
Anyway, *how* can I force the select() in the main function to release
when I'm inside the _select_receive() function???

This is a showstopper problem right now and I have a dead-line 1:st of March
so please, don't hesitate to answer :slight_smile:

/Lars
 
 
 

Within your _select_receive function
errno = EINTR; // or something else if you prefer
return -1;

select will then return -1.

Marty

“Lars Petersson” <larsp@nada.kth.se> wrote in message
news:3A994CF4.1ABB60BE@nada.kth.se
Ok this is my problem:
I have an application that is supposed to receive both QNX-messages and
socket
connections at the same time which means that I have to make select() react
to both. This is done by using (the poorly documented) function
_select_receive()
which when present is called automatically from within the normal select().
Here is some simplified a-little-bit-more-than-pseudo code that shows the
problem:
pid_t _select_receive(pid_t proxy)

char buf[DEFAULT_RECV_SIZE];
pid = Receive(0, buf, DEFAULT_RECV_SIZE );
// The “documentation” says that this function is not
// allowed to return until the proxy it was passed has been
// triggered.
while (pid !=
xy){
// Do stuff with the QNX-messages that was received.
HandleQNXReceive(pid, buf, DEFAULT_RECV_SIZE);
pid = Receive(0, buf, DEFAULT_RECV_SIZE );
}
return pid;
}

main()
{
while(1){
select(usual parameters);
HandleSelectReturnStuff();
// The select() above will only release for timeouts and regular file descriptor events
// as usual. Not for QNX-messages. In the case where you only are using sockets,
// one can write code that releases the select() and the event is taken care of. Depending
// on the event, you might want to go into select() again with for instance a new timeout
// or a new set of parameters. My problem now is that when an event comes in as a QNX-
// message and I also then want to change the timeout lets say, how do I do that from
// within the _select_receive() function? You see, when a QNX-message has been
// handled, select() calls _select_receive() again internally, not let
ting my main program
// do any actions.
}
}

Looks like I wrote most of my question in that comment :slight_smile:
Anyway, how can I force the select() in the main function to release
when I’m inside the _select_receive() function???
This is a showstopper problem right now and I have a dead-line 1:st of March
so please, don’t hesitate to answer :slight_smile:
/Lars

In article <3A994CF4.1ABB60BE@nada.kth.se>,
Lars Petersson <larsp@nada.kth.se> wrote:

!doctype html public “-//w3c//dtd html 4.0 transitional//en”

Please don’t post HTML to newsgroups. Many people prefer text-based
news readers. There was a chance I might have read your post and gave
some answer until I got to the last line below with the non-breaking
spaces. Chances are the same is true of a majority of readers.


html
Ok this is my problem:
p>I have an application that is supposed to receive both QNX-messages
and socket
br>connections at the same time which means that I have to make select()
react
br>to both. This is done by using (the poorly documented) function _select_receive()
br>which when present is called automatically from within the normal select().
p>Here is some simplified a-little-bit-more-than-pseudo code that shows
the problem:
p>pid_t _select_receive(pid_t proxy) {
br>    char buf[DEFAULT_RECV_SIZE];

Steve Furr email: furr@qnx.com
QNX Software Systems, Ltd.

Hmmm… I didn’t know my newsreader produced HTML. I don’t like HTML
myself since I usually use Pine… I think I turned it off now
though.

/Lars


Please don’t post HTML to newsgroups. Many people prefer text-based
news readers. There was a chance I might have read your post and gave
some answer until I got to the last line below with the non-breaking
spaces. Chances are the same is true of a majority of readers.

Ok this is my problem:

I have an application that is supposed to receive both QNX-messages and
socket
connections at the same time which means that I have to make select()
react
to both. This is done by using (the poorly documented) function
_select_receive()
which when present is called automatically from within the normal
select().

Here is some simplified a-little-bit-more-than-pseudo code that shows
the problem:

pid_t _select_receive(pid_t proxy) {
char buf[DEFAULT_RECV_SIZE];

pid = Receive(0, buf, DEFAULT_RECV_SIZE );

// The “documentation” says that this function is not
// allowed to return until the proxy it was passed has been
// triggered.
while (pid != proxy){
// Do stuff with the QNX-messages that was received.
HandleQNXReceive(pid, buf, DEFAULT_RECV_SIZE);

pid = Receive(0, buf, DEFAULT_RECV_SIZE );
}

return pid;
}


main()
{
while(1){
select(usual parameters);

HandleSelectReturnStuff();

// The select() above will only release for timeouts and regular
file // descriptor events as usual. Not for QNX-messages. In the case
where // you only are using sockets, one can write code that
releases the // select() and the event is taken care of.
Depending on the event, you // might want to go into select()
again with for instance a new timeout
// or a new set of parameters. My problem now is that when an
event // comes in as a QNX- message and I also then want to
change the // timeout lets say, how do I do that from
within the _select_receive() // function? You see, when a
QNX-message has been handled, select() // calls
_select_receive() again internally, not letting my main
// program do any actions.
}
}


Looks like I wrote most of my question in that comment :slight_smile:
Anyway, how can I force the select() in the main function to release
when I’m inside the _select_receive() function???

This is a showstopper problem right now and I have a dead-line 1:st of
March
so please, don’t hesitate to answer :slight_smile:

/Lars

I thought I tested that (return -1), but I’ll try it. Thanks!

/Lars


Marty Doane wrote:

Within your _select_receive function
errno = EINTR; // or something else if you prefer
return -1;

select will then return -1.

Marty

Check this:

ftp://ftp.qnx.com/usr/free/qnx4/tcpip/examples/selio.c.gz
ftp://ftp.qnx.com/usr/free/qnx4/tcpip/examples/selio.c.gz.readme

-xtang

Lars Petersson <larsp@nada.kth.se> wrote:

Ok this is my problem:

I have an application that is supposed to receive both QNX-messages and
socket
connections at the same time which means that I have to make select()
react
to both. This is done by using (the poorly documented) function
_select_receive()
which when present is called automatically from within the normal
select().

Here is some simplified a-little-bit-more-than-pseudo code that shows
the problem:

pid_t _select_receive(pid_t proxy) {
char buf[DEFAULT_RECV_SIZE];

pid = Receive(0, buf, DEFAULT_RECV_SIZE );

// The “documentation” says that this function is not
// allowed to return until the proxy it was passed has been
// triggered.
while (pid != proxy){
// Do stuff with the QNX-messages that was received.
HandleQNXReceive(pid, buf, DEFAULT_RECV_SIZE);

pid = Receive(0, buf, DEFAULT_RECV_SIZE );
}

return pid;
}


main()
{
while(1){
select(usual parameters);

HandleSelectReturnStuff();

// The select() above will only release for timeouts and regular
file // descriptor events as usual. Not for QNX-messages. In the case
where // you only are using sockets, one can write code that
releases the // select() and the event is taken care of.
Depending on the event, you // might want to go into select()
again with for instance a new timeout
// or a new set of parameters. My problem now is that when an
event // comes in as a QNX- message and I also then want to
change the // timeout lets say, how do I do that from
within the _select_receive() // function? You see, when a
QNX-message has been handled, select() // calls
_select_receive() again internally, not letting my main
// program do any actions.
}
}


Looks like I wrote most of my question in that comment > :slight_smile:
Anyway, how can I force the select() in the main function to release
when I’m inside the _select_receive() function???

This is a showstopper problem right now and I have a dead-line 1:st of
March
so please, don’t hesitate to answer > :slight_smile:

/Lars