Stream live video from phone to phone using socket fd

I found an open source project for implementing what I was trying. It processes the video with metadata through an IP camera. Although it does not send video directly to a phone, it does broadcast video for various devices to watch. The source code can be found at the following project page http://code.google.com/p/ipcamera-for-android/. With Android … Read more

What can lead to “IOError: [Errno 9] Bad file descriptor” during os.system()?

You get this error message if a Python file was closed from “the outside”, i.e. not from the file object’s close() method: >>> f = open(“.bashrc”) >>> os.close(f.fileno()) >>> del f close failed in file object destructor: IOError: [Errno 9] Bad file descriptor The line del f deletes the last reference to the file object, … Read more

Getting the highest allocated file descriptor

While portable, closing all file descriptors up to sysconf(_SC_OPEN_MAX) is not reliable, because on most systems this call returns the current file descriptor soft limit, which could have been lowered below the highest used file descriptor. Another issue is that on many systems sysconf(_SC_OPEN_MAX) may return INT_MAX, which can cause this approach to be unacceptably … Read more

Retrieving file descriptor from a std::fstream [duplicate]

You can go the other way: implement your own stream buffer that wraps a file descriptor and then use it with iostream instead of fstream. Using Boost.Iostreams can make the task easier. Non-portable gcc solution is: #include <ext/stdio_filebuf.h> { int fd = …; __gnu_cxx::stdio_filebuf<char> fd_file_buf{fd, std::ios_base::out | std::ios_base::binary}; std::ostream fd_stream{&fd_file_buf}; // Write into fd_stream. // … Read more