At the top of your application, include vmci_sockets.h and declare a constant for the socket buffer size. In the example below,
BUFSIZE defines the socket buffer size. It is not based on the size of a TCP packet.
VMCISock_GetAFValue() returns a descriptor for the vSockets address family if available.
The connect() call requests a socket connection to the server specified by CID in the
sockaddr_vm structure, instead of by the IP address in the
sockaddr_in structure.
The sockaddr_vm structure contains an element for the context ID (CID) to specify the virtual machine or host. The client making a connection should provide the CID of a remote virtual machine or host.
The connect() call allows you to use
send() and
recv() functions instead of
sendto() and
recvfrom(). The
connect() call is not necessary for datagram sockets.
The send() call writes data to the server application. The client and server can communicate the length of data transmitted, or the server can terminate its
recv() loop when the client closes its connection.
The recv() call reads data from the server application. Sometimes the server sends flow control information, so the client must be prepared to receive it. Use the same socket descriptor as for
send().
The close() call shuts down a connection, given the original socket descriptor obtained from the
socket() function. To compile on Windows, you must call the Winsock
closesocket() instead of
close().
Not all socket-based networking programs use poll(), but if they do, no changes are required.
The read() and
write() socket calls are provided for convenience. They provide the same functionality as
recv() and
send().