[FFmpeg-devel] MinGW network support

Michel Bardiaux mbardiaux
Mon May 21 17:36:25 CEST 2007

Alex Beregszaszi wrote:
> Hi,
>>> Without this hack, ffserver is not working. Can you give me an
>>> explanation why does Winsock returns socket numbers like 1754 and 1800?
>>> Can I influence this to return normal socket numbers starting from 3 ?
>> I would venture the guess these are actual port numbers. It seems 
> Yes, it is likely a port number.
>> unlikely you can force socket() to return 'normal' values, because it is 
>> rather clear from the winsock documentation that sockets are *NOT* 
>> 'files' but entities with their own API.
> However, then why don't they implement select() working with this idea?
> It does not work right with such socket numbers.

select() on Windows works right *if* you follow the guidelines found in 
the official winsock doc:

Four macros are defined in the header file Winsock2.h for manipulating 
and checking the descriptor sets. The variable FD_SETSIZE determines the 
maximum number of descriptors in a set. (The default value of FD_SETSIZE 
is 64, which can be modified by defining FD_SETSIZE to another value 
before including Winsock2.h.) Internally, socket handles in an fd_set 
structure are not represented as bit flags as in Berkeley Unix. Their 
data representation is opaque. Use of these macros will maintain 
software portability between different socket environments. The macros 
to manipulate and check fd_set contents are:

FD_CLR(s, *set)
Removes the descriptor s from set.
FD_ISSET(s, *set)
Nonzero if s is a member of the set. Otherwise, zero.
FD_SET(s, *set)
Adds descriptor s to set.
Initializes the set to the NULL set.

Is this broken? Rigorously, no. Is this an extreme case of NIH syndrome? 
I would say yes. They *could* have kept the winsock implementation more 
compatible with BSD down to the deepest internals, after all they 
managed it for the C library, and for a lot of nix-like calls like open().

In any case, *dont* expect select() to work on anything else then 
sockets on MS-W. If ffserver (or any other) depends on select on 
non-socket (and on MS-W pipes are not sockets!), then it will be 
difficult to port to MINGW.

Michel Bardiaux
R&D Director
T +32 [0] 2 790 29 41
F +32 [0] 2 790 29 02
E mailto:mbardiaux at mediaxim.be

Mediaxim NV/SA
Vorstlaan 191 Boulevard du Souverain
Brussel 1160 Bruxelles

More information about the ffmpeg-devel mailing list