using select to read STDIN?

I

ifmusic

Hi!, i have a "server-like" application:
i use select to accept and recieve data from Sockets.
I want to Add a menu to this app something like "pick an option" thing,
but it has to show data according to data recieved from Sockets..

I found a way to do it with Fork, i mean, First i fork;in the Child i
do all the menu stuff and in the "else" part (the parent part) i have
the rest (the while(1) with a select inside). But i dont like this
because, i don't like forking just for a menu! and i have to create a
socket to communicate with the parent.

i was thinking.. isn't it possible to tell the select to read and show
the stdin, after all, it's a FD.
I tried this but i couldn't get it to work correctly, i ran into
trouble like "recv cant read from a Non-socket fd" "i read the stdin
with "read" but i reads char by char -i guess- and it remains "ready"
so select, keeps selecting stdin forever.

so, i don't know which is THE way to do it correcly if there is such a
thing.

Thanks.
 
R

Robert Gamble

Hi!, i have a "server-like" application:
i use select to accept and recieve data from Sockets.
I want to Add a menu to this app something like "pick an option" thing,
but it has to show data according to data recieved from Sockets..

I found a way to do it with Fork, i mean, First i fork;in the Child i
do all the menu stuff and in the "else" part (the parent part) i have
the rest (the while(1) with a select inside). But i dont like this
because, i don't like forking just for a menu! and i have to create a
socket to communicate with the parent.

i was thinking.. isn't it possible to tell the select to read and show
the stdin, after all, it's a FD.
I tried this but i couldn't get it to work correctly, i ran into
trouble like "recv cant read from a Non-socket fd" "i read the stdin
with "read" but i reads char by char -i guess- and it remains "ready"
so select, keeps selecting stdin forever.

so, i don't know which is THE way to do it correcly if there is such a
thing.

This is the wrong group, we limit our discussions to Standard C here
which does not include sockets, forking, etc.; try
comp.unix.programmer.

Robert Gamble
 
C

CBFalconer

Hi!, i have a "server-like" application:
i use select to accept and recieve data from Sockets.
I want to Add a menu to this app something like "pick an option" thing,
but it has to show data according to data recieved from Sockets..

I found a way to do it with Fork, i mean, First i fork;in the Child i
do all the menu stuff and in the "else" part (the parent part) i have
the rest (the while(1) with a select inside). But i dont like this
because, i don't like forking just for a menu! and i have to create a
socket to communicate with the parent.

You probably want a newsgroup with 'restaurant' or 'dining' or
something like that in its name. This is comp.lang.c, which has
nothing whatsoever to do with menus, selecting therefrom, forks,
serving, sockets, parents. There is also a remote chance that
comp.unix.programmer would be useful.

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell.org/google/>
Also see <http://www.safalra.com/special/googlegroupsreply/>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,183
Messages
2,570,967
Members
47,517
Latest member
Andres38A1

Latest Threads

Top