recvfrom blocking to non-blocking

Hello guys,
in recvfrom function of socket programming, i believe it's a blocking function
and when calling it, it waits to receive data and block the whole program if no data received.
i want to use it such that, when it finds no data it will continue and skip this instruction and the rest of program should be executed

1
2
3
4
5
6
7
8
int iResult = 0;
SOCKET RecvSocket;
iResult = recvfrom(RecvSocket,buffer,buffer_size , 0, (SOCKADDR *) & SenderAddr, &SenderAddrSize);
while(1)
{
outfile.write(buffer);
iResult = recvfrom(RecvSocket,buffer,buffer_size , 0, (SOCKADDR *) & SenderAddr, &SenderAddrSize);
}


when we get all data i want it to get out from this infinite loop
but it can't because it's a blocking call

can you help me to make recvfrom of a non-blocking call?
i've heard that i can change socket type to be non-blocking
but how can i do that??

Thanks in advance.
Problem solved using
ioctlsocket function :)
Topic archived. No new replies allowed.