\nint getsockname(\n SOCKET s, \n struct sockaddr FAR *name, \n int FAR *namelen \n);\n\n(The above taken from the WinSock documentation)
A SOCKET is a "handle" to a socket object. How this "handle" is implemented is implementation-dependent, but on Windoze platforms, handles are defined as pointers. Indeed, the definition of a SOCKET in winsock.h is:
\ntypedef UINT_PTR SOCKET;\n
where a
UINT_PTR
is a pointer to an unsigned int.So what you're doing is implicitly casting an
int
to a pointer type, and the compiler is (rightly) bitching about it.To fix it, define the parameter
f
as type SOCKET instead of type int, or explicitly cast f to the SOCKET type. <rant>
(NOTE: I don't give a flying shit if these yahoos are from the mighty MIT, passing a socket handle as an
int
instead of as a SOCKET
is really bad coding!. If this is what MIT is pumping out, then it's no wonder why the Indians are eating our lunch!)</rant>