select() and Receive()

Hiya,
I’m working on a test app to find the best way to handle selecting off of
file descriptors (specifically input from the serial port) and Receive()
from processes that want to send data to it (send messages that will be
output on that particular serial port). I haven’t found a way to mix the
select and Receive stuff yet (if it is even possible) without implementing
timeouts (I’d prefer to not have to put timeouts in on the select call if I
don’t have to).

Is there a way to do this, either handle the Receives on the select call, or
vice-versa (handle the select through the Receive call)? If it’s not
possible, I could always throw a second process into the app, one that
handles read()ing off the serial port, Send()s the data to the other
process, while the other one Receive()s requests and data from the other
process, and write()s out the serial port if it needs to. I’d prefer to
keep it within one process however if possible.

Any help is appreciated! TIA!

Ron

pid_t _select_receive(pid_t proxy)

is described in “select()” function in “Watcom C Library - N to Z”,
page 903 - 904

-xtang

Ron Cococcia <cococr@cs.rpi.edu> wrote:

Hiya,
I’m working on a test app to find the best way to handle selecting off of
file descriptors (specifically input from the serial port) and Receive()
from processes that want to send data to it (send messages that will be
output on that particular serial port). I haven’t found a way to mix the
select and Receive stuff yet (if it is even possible) without implementing
timeouts (I’d prefer to not have to put timeouts in on the select call if I
don’t have to).

Is there a way to do this, either handle the Receives on the select call, or
vice-versa (handle the select through the Receive call)? If it’s not
possible, I could always throw a second process into the app, one that
handles read()ing off the serial port, Send()s the data to the other
process, while the other one Receive()s requests and data from the other
process, and write()s out the serial port if it needs to. I’d prefer to
keep it within one process however if possible.

Any help is appreciated! TIA!

Ron

Xiaodan Tang <xtang@qnx.com> wrote:

pid_t _select_receive(pid_t proxy)

is described in “select()” function in “Watcom C Library - N to Z”,
page 903 - 904

That is one way of doing it – the other is to use the asynchronous
notification of socket I/O.

Look at the TCP/IP Programmers Guide, chapter 3 An Advanced Socket
Communications Tutorial
, Advance Topics section, Interrupt-driven
socket I/O subsection. You can get a SIGIO whenever there is something
“new” on a socket. Then, you use Receive() as your blocking point,
mask signals after the Receive(), unmask them before, and Trigger()
a proxy in your SIGIO signal handler. Then if you Receive() the SIGIO
proxy, call a non-blocking select() to determine which fd(s) have data,
some should as you got a signal to tell you so.

-David

-xtang

Ron Cococcia <> cococr@cs.rpi.edu> > wrote:
Hiya,
I’m working on a test app to find the best way to handle selecting off of
file descriptors (specifically input from the serial port) and Receive()
from processes that want to send data to it (send messages that will be
output on that particular serial port). I haven’t found a way to mix the
select and Receive stuff yet (if it is even possible) without implementing
timeouts (I’d prefer to not have to put timeouts in on the select call if I
don’t have to).

Is there a way to do this, either handle the Receives on the select call, or
vice-versa (handle the select through the Receive call)? If it’s not
possible, I could always throw a second process into the app, one that
handles read()ing off the serial port, Send()s the data to the other
process, while the other one Receive()s requests and data from the other
process, and write()s out the serial port if it needs to. I’d prefer to
keep it within one process however if possible.

Any help is appreciated! TIA!

Ron


QNX Training Services
dagibbs@qnx.com

I went in and wrote my own _select_receive, but it never gets called.
Anybody have an idea as to how to make select() use my _select_receive
instead of it’s own?

TIA,
Ron

“Xiaodan Tang” <xtang@qnx.com> wrote in message
news:9gdgdl$6mg$2@nntp.qnx.com

pid_t _select_receive(pid_t proxy)

is described in “select()” function in “Watcom C Library - N to Z”,
page 903 - 904

-xtang

Ron Cococcia <> cococr@cs.rpi.edu> > wrote:
Hiya,
I’m working on a test app to find the best way to handle selecting off
of
file descriptors (specifically input from the serial port) and Receive()
from processes that want to send data to it (send messages that will be
output on that particular serial port). I haven’t found a way to mix
the
select and Receive stuff yet (if it is even possible) without
implementing
timeouts (I’d prefer to not have to put timeouts in on the select call
if I
don’t have to).

Is there a way to do this, either handle the Receives on the select
call, or
vice-versa (handle the select through the Receive call)? If it’s not
possible, I could always throw a second process into the app, one that
handles read()ing off the serial port, Send()s the data to the other
process, while the other one Receive()s requests and data from the other
process, and write()s out the serial port if it needs to. I’d prefer to
keep it within one process however if possible.

Any help is appreciated! TIA!

Ron

Are you writing/compiling in C++? If so, you need to protect your
_select_receive with:

extern “C”

Ron Cococcia wrote:

I went in and wrote my own _select_receive, but it never gets called.
Anybody have an idea as to how to make select() use my _select_receive
instead of it’s own?

TIA,
Ron

“Xiaodan Tang” <> xtang@qnx.com> > wrote in message
news:9gdgdl$6mg$> 2@nntp.qnx.com> …
pid_t _select_receive(pid_t proxy)

is described in “select()” function in “Watcom C Library - N to Z”,
page 903 - 904

-xtang

Ron Cococcia <> cococr@cs.rpi.edu> > wrote:
Hiya,
I’m working on a test app to find the best way to handle selecting off
of
file descriptors (specifically input from the serial port) and Receive()
from processes that want to send data to it (send messages that will be
output on that particular serial port). I haven’t found a way to mix
the
select and Receive stuff yet (if it is even possible) without
implementing
timeouts (I’d prefer to not have to put timeouts in on the select call
if I
don’t have to).

Is there a way to do this, either handle the Receives on the select
call, or
vice-versa (handle the select through the Receive call)? If it’s not
possible, I could always throw a second process into the app, one that
handles read()ing off the serial port, Send()s the data to the other
process, while the other one Receive()s requests and data from the other
process, and write()s out the serial port if it needs to. I’d prefer to
keep it within one process however if possible.

Any help is appreciated! TIA!

Ron

I had done that, but nothing happened. Then I noticed one of the tragic
mistakes of not listening to your teachers in school… I had spelt receive
“recieve” in my code… So, it works now, but I feel very depressed…

“Dean Douthat” <ddouthat@faac.com> wrote in message
news:3B311076.3C740DFA@faac.com

Are you writing/compiling in C++? If so, you need to protect your
_select_receive with:

extern “C”

Ron Cococcia wrote:

I went in and wrote my own _select_receive, but it never gets called.
Anybody have an idea as to how to make select() use my _select_receive
instead of it’s own?

TIA,
Ron

“Xiaodan Tang” <> xtang@qnx.com> > wrote in message
news:9gdgdl$6mg$> 2@nntp.qnx.com> …
pid_t _select_receive(pid_t proxy)

is described in “select()” function in “Watcom C Library - N to Z”,
page 903 - 904

-xtang

Ron Cococcia <> cococr@cs.rpi.edu> > wrote:
Hiya,
I’m working on a test app to find the best way to handle selecting
off
of
file descriptors (specifically input from the serial port) and
Receive()
from processes that want to send data to it (send messages that will
be
output on that particular serial port). I haven’t found a way to
mix
the
select and Receive stuff yet (if it is even possible) without
implementing
timeouts (I’d prefer to not have to put timeouts in on the select
call
if I
don’t have to).

Is there a way to do this, either handle the Receives on the select
call, or
vice-versa (handle the select through the Receive call)? If it’s
not
possible, I could always throw a second process into the app, one
that
handles read()ing off the serial port, Send()s the data to the other
process, while the other one Receive()s requests and data from the
other
process, and write()s out the serial port if it needs to. I’d
prefer to
keep it within one process however if possible.

Any help is appreciated! TIA!

Ron

Ron Cococcia <cococr@cs.rpi.edu> wrote:

I had done that, but nothing happened. Then I noticed one of the tragic
mistakes of not listening to your teachers in school… I had spelt receive
“recieve” in my code… So, it works now, but I feel very depressed…

:frowning:

-David

QNX Training Services
dagibbs@qnx.com