filedescriptor

Opening pipe connection to a file descriptor in C#

I have a legacy app where it reads message from a client program from file descriptor 3. This is an external app so I cannot change this. The client is written in C#. How can we open a connection to a specific file descriptor in C#? Can we use something like AnonymousPipeClientStream()? But how do we specify the file descriptor to connec...

How to use the select() function in socket programming?

The prototype is: int select (int nfds, fd_set *read-fds, fd_set *write-fds, fd_set *except-fds, struct timeval *timeout); I've been struggling to understand this function for quite some time. My question is, if it checks all the file descriptors from 0 to nfds-1, and will modify the rea...

Increasing the number of file descriptors in Linux.

I have a long running process which monitors the system and prints periodic logs. If I let it run for longer than 10-15 minutes, it exits with a message saying: Too many open files. The program is setup using real time timer_create() and timer_settime() which raise a SIGUSR1 every 2 seconds. In the handler, there is one fork()-exec() in...

Example for using Python Twisted with File Descriptors

I'm looking to use twisted to control communication across Linux pipes (os.pipe()) and fifos (os.mkfifo()) between a master process and a set of slave processes. While I'm positive tat it's possible to use twisted for these types of file descriptors (after all, twisted is great for tcp sockets which *nix abstracts away as file descriptor...

Range for FD (File Descriptor) in Linux

Possible Duplicate: Is 0 or 1 valid return values for socket() function call what is the range for FD(File Descriptor)? For example : int sockfd = socket(AF_INET, SOCK_STREAM, 0); or newsockfd = accept(sockfd, (struct sockaddr *) & cli_addr, (socklen_t *) & clilen); what is the range sockfd , newsockfd ? Are these >...

What is the theoretical maximum number of open TCP connections that a modern Linux box can have.

Assuming infinite performance from hardware, can a Linux box support >65536 open TCP connections? I understand that the number of ephemeral ports (<65536) limits the number of connections from one local IP to one port on one remote IP. The tuple (local ip, local port, remote ip, remote port) is what uniquely defines a TCP connection; d...

Duplicate file descriptor after popen

I am using popen to execute a command under linux, then 4 process wile use the same output. I am trying to duplicate the file descriptor again to pass it to each process. here is my code: FILE* file_source = (FILE*) popen(source_command, "r"); int fd = fileno(file_source); fdatasync(fd); int dest_fd[4], y, total = 4; for (y = 0; y ...

C: how to redirect stderr from System-command to stdout or file?

The shell command $ avrdude -c usbtiny outputs text to stderr. I cannot read it with commmands such as head-less-more cos it is not stdout. I want the text to stdout or to a file. How can I do it in C? I have tried to solve the problem by my last question but still unsolved. ...

fopen problem - too many open files

I have a multithreaded application running on Win XP. At a certain stage one of a threads is failing to open an existing file using fopen function. _get_errno function returns EMFILE which means Too many open files. No more file descriptors are available. FOPEN_MAX for my platform is 20. _getmaxstdio returns 512. I checked this with WinD...

Ensure a file is not changed while trying to remove it

In a POSIX environment, I want to remove a file from disk, but calculate its checksum before removing it, to make sure it was not changed. Is locking enough? Should I open it, unlink, calculate checksum, and then close it (so the OS can remove its inode)? Is there any way to ensure no other process has an open file descriptor on the file...

Problem in code with File Descriptors. C (Linux)

I've written code that should ideally take in data from one document, encrypt it and save it in another document. But when I try executing the code it does not put the encrypted data in the new file. It just leaves it blank. Someone please spot what's missing in the code. I tried but I couldn't figure it out. I think there is something...

Why does the following code raise a SegFault. c(Linux)

This a code that would reverse the data of a document and save it in the same document itself. However I am getting a Segmentation Fault.Please Help,I don't know why it gives a SegFault. #include <stdio.h> #include <stdlib.h> #include <termios.h> #include <fcntl.h> #include <string.h> #include <unistd.h> int main (int argc,char* argv[...

How to iterate through a fd_set

Hello. I'm wondering if there's an easy way to iterate through a fd_set? The reason I want to do this is to not having to loop through all connected sockets, since select() alters these fd_sets to only include the ones I'm interested about. I also know that using an implementation of a type that is not meant to be directly accessed is ge...

Python persistent socket connection

Hello, I'm new to python :) I would like to create persistent socket. I tried to do this using file descriptors. What I tried is: Open a socket socket connection s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) Get it's file descriptor number fd = s.fileno() Open the file descriptor as I/O os.open(fd) But I get OSError: [Errno ...