The flowchart in Connectionless Datagram Sockets shows how to establish connectionless sockets on the server and client.
In UDP sockets, the server waits for the client to transmit, and accepts datagrams. In vSockets, the server and client communicate similarly with datagrams.
Preparing the Server for a Connection
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. The number 4096 is a good choice for efficiency on multiple platforms. It is not based on the size of a UDP datagram.
#include "vmci_sockets.h" #define BUFSIZE 4096
To compile on Windows, you must call the Winsock WSAStartup() function.
err = WSAStartup(versionRequested, &wsaData); if (err != 0) { printf(stderr, "Could not register with Winsock DLL.\n"); goto exit; }