Call VMCISock_GetAFValue() to obtain the VMCI address family. Declare structure
sockaddr_vm instead of
sockaddr_in. In the
socket() call, replace the
AF_INET address family with the VMCI address family.
In virtual hardware version 7 (Workstation 6.5 releases), the VMCI virtual device is present by default. When you create a virtual machine, the .vmx configuration file contains lines specifying PCI slot number and the ID of the VMCI device. On the
vmci0.id line, CID is the number in double quotes.
For convenience, you can call the VMCISock_GetLocalCID() function to obtain the local system’s CID. This function works on both the ESXi host and guest virtual machines, although the ESXi host always has CID = 2, even in a nested virtual machine (VM running in a VM).
To initialize the address structure passed to bind(), insert these source code statements, where
sockaddr_vm for vSockets replaces
sockaddr_in for network sockets.
The first line declares my_addr as a
sockaddr_vm structure and initializes it with zeros.
AF_INET replaces
afVMCI. Both
VMADDR_CID_ANY and
VMADDR_PORT_ANY are predefined so that at runtime, the server can fill in the appropriate CID and port values during a bind operation. The initiating side of the connection, the client, must provide the CID and port, instead of
VMADDR_CID_ANY and
VMADDR_PORT_ANY.