winapinetwork-programmingwinsock2windows-networking

WSAAccept return size not changing


I'm having difficulties using WSAAccept function. I'm using this function on Windows Phone platform. MSDN says this function is supported on Windows Phone, but unfortunately this function never returns me the right length of the sockaddr structure pointed to by the addr parameter. Even if i pass ridicolouos value, it's not changed upon returning.

Has anyone any ideas what could be done to fix that and what could be the reason of such behaviour ?

I will greatly appreciate any help.

EDIT This is how the function is used:

sockaddr address;
int size = 28; //it is a max size of union in which it is stored address;

c=accept(s,&address,&size); //where s is the socket;

but because accept is not supported on Windows Phone platform, i have a wrapper for it:

SOCKET accept(
        SOCKET s,
        struct sockaddr *addr,
        int *addrlen
        )
    {
        return c = WSAAccept(s, addr, addrlen, NULL, NULL);
    }

Solution

  • I managed to get proper addrlen by calling getpeername function after accept function. For now it solved the problem.