WSArecv() or recv()?

Started by
2 comments, last by Nylren 21 years, 1 month ago
Which one should I use and why? The books i have on networking the only talk about recv, now I found WSArecv(), is there any difference? THanks, Nylren
Advertisement
Depends on how complex your I/O strategy needs to be. WSARecv() allows two fundamental improvements over the traditional recv(): you can declare multiple receive buffers and a callback function to be summoned when all of the buffers have been filled (leading to greater efficiency if your program requires this kind of scatter-gather technique), and you can perform overlapped socket operations that allow you to queue multiple reads and wait for each individual completion by waiting on event handles. Also, WSARecv() tells you if there is more data waiting in the network buffer through the use of the lpFlags parameter (referred to as the MSG_PARTIAL flag). If you need this kind of functionality, feel free to switch over.

Simplistic receive operations may be performed with either function, but recv() is often the best and most straightforward choice if none of WSARecv()'s features are needed.

RapscallionGL - arriving soon.

[edited by - johnnie2 on March 7, 2003 7:58:12 PM]
________________________________________________"Optimal decisions, once made, do not need to be changed." - Robert Sedgewick, Algorithms in C
Use WSARecv() because supports non-blocking I/O including OVERLAPPED and IOCP.

Kuphryn
Thanks

This topic is closed to new replies.

Advertisement