473,396 Members | 2,004 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

using select to read STDIN?

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.

May 16 '06 #1
3 3704
if*****@gmail.com wrote:
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

May 16 '06 #2

ok, i will

sorry.

May 16 '06 #3
if*****@gmail.com wrote:

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/>
May 16 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Chuck Anderson | last post by:
Can anyone point me in the right direction? I want to use Php to automate confirmation of someone joining an email list by them replying to an email (so they don't have to have a browser?). I...
3
by: Harayasu | last post by:
Hi, Using fgets() I can read from stdin and with fputs() I can write to stdout. Now I have two programs, one writing to stdin and the other one reading from stdin. And I would like the second...
3
by: Marcia Hon | last post by:
Hi, I am trying to use the select() socket programming command to select between stdin and a connection. Currently, I have a listening stream and stdin that I insert into the fd_set. The problem...
6
by: Charlie Zender | last post by:
Hi, I have a program which takes the output filename argument from stdin. Once the program knows the output filename, it tries to open it. If the output file exists, the program asks the user to...
1
by: asdsd sir | last post by:
Hi!I'm new in Python and i'd like to ask some general questions about stdin,stdout... Firstly... if we type like something like : cat "file.txt"|python somefile.py #somefile.py import sys
1
by: bobano | last post by:
Hi everyone, I am writing a POP3 Client program in Perl. You connect to a POP3 Server and have a running conversation with the mail server using commands from the RFC 1939 Post Office Protocol....
5
by: Dio | last post by:
#!/usr/bin/env python2 from sys import stdin from select import select while 1: (rr, wr, er) = select(, , ) for fd in rr: print fd
0
by: timekeer9 | last post by:
Hi, I would like to poll stdin for input so I can get user input from the command line without blocking. Looking through the archives, it appears that the best way to do this is using a combination...
7
by: Samuel A. Falvo II | last post by:
I have a shell script script.sh that launches a Java process in the background using the &-operator, like so: #!/bin/bash java ... arguments here ... & In my Python code, I want to invoke...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.