473,378 Members | 1,482 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,378 software developers and data experts.

How does the file descriptor work on given C code

56
I am new to C programming file descriptor concept , working in an already developed code base. I have no idea regarding the following file descriptor concept .

Expand|Select|Wrap|Line Numbers
  1. if (misc->playing == -1 || misc->cd_type != CDIO_DISC_MODE_CD_DA)
  2.       {
  3.          fd_set rfds;
  4.          struct timeval tv;
  5.  
  6.          FD_ZERO (&rfds);
  7.          FD_SET (0, &rfds);
  8.          tv.tv_sec = 0;
  9.          tv.tv_usec = 100000;
  10. // pause till a key has been pressed or 0.1 misc->elapsed_seconds are elapsed
  11.          select (1, &rfds, NULL, NULL, &tv);
  12.       } // if
  13.  
Please waiting for your fast response.

Thanks
Anes P A
Jan 6 '16 #1
4 1346
weaknessforcats
9,208 Expert Mod 8TB
Have you read about:

Expand|Select|Wrap|Line Numbers
  1. select (1, &rfds, NULL, NULL, &tv);

The select function appears in various forms of socket programming. I know there is a Wikipedia for the UNIX version of this function written by the Open Group which has a lot more info than I can post here.

Check it out.
Jan 6 '16 #2
donbock
2,426 Expert 2GB
Type fd_set and functions FD_ZERO(), FD_SET(), and select() are not part of the C Standard. Presumably they are provided by the operating system.
What operating system are you using?

Your operating system may vary, but typically the return value from select() is useful.
Jan 6 '16 #3
amskape
56
Dear donbock,
I am using Ubuntu 15.10. The application is a C written program running in ubuntu...
advise me

Thanks
Anes
Jan 7 '16 #4
donbock
2,426 Expert 2GB
Your code snippet is very similar to the example in the Ubuntu man page for select, et.al.. What questions remain after reading this?
Jan 7 '16 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: wordsender | last post by:
Hey guys, I can't figure this one out, why is this simple script giving me problems? logfile=file(r'test.txt','w') logfile.write('datetime') test=logfile.readlines() When I run it I get...
1
by: Patrick LeBoutillier | last post by:
Hi all, I'm trying to perform read and write I/O on a socket file descriptor received for another process via a Unix Domain Socket. In trying to understand all this I came up with a small test...
1
by: Robert Schweikert | last post by:
Hi, I am trying to get uses of iostream up to par with the new iostream model, i.e. standard C++ I/O streams. I have run into some problems and was able to work around most of them. However,...
6
by: Siddharth Taneja | last post by:
Hi, I have a very simple prg over here, trying to read the lines of a file #include <iostream> #include <fstream> #include <iostream> #include <string> using namespace std;
3
by: gipsy boy | last post by:
Given a file descriptor (from a network socket, for instance), I want to have an iostream that reads/writes to it, so I can push and read data in the traditional way : sockStream << "<some...
4
by: CSN | last post by:
At startup this appears in the log: WARNING: dup(0) failed after 3195 successes: Bad file descriptor What does it mean? __________________________________________________
7
by: news | last post by:
Recently our mail from our e-commerce site has been rejected by AOL due to an IP block because someone was using our PHP scripts to send spam. Well, I got that fixed. But our legitimate...
4
by: darrin.skinner | last post by:
Hi all, How can I open a file/pipe to something other than STDOUT/STDERR? I.e. I want to write to file descriptor # 3. fopen("php://std3"... does not work. fopen("/dev/ttyS3"... does not...
9
by: Bill David | last post by:
I know it's very strange to do that since we have the file name when we call: int open(const char *pathname, int oflag,...); And we can store the file name for later usage. But I just wonder if...
3
by: paleman | last post by:
Hi. I'm trying to write my own version of opendir function on Windows XP.Within that function I'm calling open function: fd = open(path, O_RDONLY, 0); and this fails when path points to a...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.