On 2013/01/10 12:24, Denis Krjuchkov <de...@crazydev.net> wrote:
> Last time I saw it MPD used int type for sockets.
> Windows API actually defines a SOCKET type which a typedef for UINT_PTR.

WTF?

> From my observations socket handles grow sequentially from small
> numbers to higher. This makes error unnoticeable.

What is the practical problem then?  After MPD has accepted its two
billionths client, further connects will fail?

> I could try to provide a patch for mpd/mpc/libmpdclient but not sure
> what's the best way to do it. Define separate type (i.e. mpd_socket)
> that always is a typedef for correct socket type. Or just #ifdef in
> each particular usage?

In MPD, there should be a class wrapping a socket descriptor, which
hides implementation specific details.

> Also this might break the API of libmpdclient and I'd like to avoid
> API breaks for other platforms.

On Linux, we could easily use symbol versions, but on Linux this isn't
a problem anyway.  I don't know if DLLs can have versioned symbols.
But on Windows, we could add another symbol for the SOCKET type, and
make all functions with "int" static+inline wrappers which cast to
SOCKET and call the new function.  Therefore, binaries which were
compiled with the new headers will use the new symbols, and old
binaries will continue to use the old symbols (which will continue to
exist as long as "2" is the major version).

------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122712
_______________________________________________
Musicpd-dev-team mailing list
Musicpd-dev-team@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/musicpd-dev-team

Reply via email to