9.0
Table Of Contents
- VMCI Sockets Programming Guide
- Contents
- About This Book
- About VMCI Sockets
- Porting to VMCI Sockets
- Creating Stream VMCI Sockets
- Creating Datagram VMCI Sockets
- Security of the VMCI Device
- Appendix: Learning More About Sockets
- Index
VMCI Sockets Programming Guide
18 VMware, Inc.
Recv() Function
Therecv()callreadsdatafromtheserverapplication.Sometimestheserversendsflowcontrolinformation,
sotheclientmustbepreparedtoreceiveit.Usethesamesocketdescriptorasforsend().
char recv_buf[BUFSIZE];
if ((numbytes = recv(sockfd, recv_buf, sizeof recv_buf, 0)) == -1) {
perror("recv");
goto close;
}
Close() Function
Theclose()callshutsdownaconnection,giventheoriginalsocketdescriptorobtainedfromthesocket()
function.TocompileonWindows,youmustcalltheWinsockclosesocket()insteadofclose().
#ifdef _WIN32
return closesocket(sockfd);
#else
return close(sockfd);
#endif
Poll() Information
Notallsocket‐basednetworkingprogramsusepoll(),butiftheydo,nochangesarerequired.
Read() and Write()
Theread()andwrite()socketcallsareprovidedforconvenience.Theyprovidethesamefunctionalityas
recv()andsend().