Introduction to vSockets
The VMware vSockets library offers an API that is similar to the Berkeley UNIX socket interface and the Windows socket interface, two industry standards. The vSockets library, built on the VMCI device, supports fast and efficient communication between guest virtual machines and their host.
Previous VMCI Releases
The original VMCI library was released as an experimental C language interface with Workstation 6.0. VMCI included a datagram API and a shared memory API. Both interfaces were discontinued in Workstation 6.5.
The vSockets library was first released with Workstation 6.5 and Server 2.0 as a supported interface. The vSockets library had more flexible algorithms, wrapped in a stream sockets API for external presentation. Stream socket support was improved for ESX/ESXi hosts when VMware vSphere™ 4 and vCenter™ Server 4 were released.
How vSockets Work
VMware vSockets are similar to other socket types. Like local UNIX sockets, vSockets work on an individual physical machine, and can perform interprocess communication on the local system. With Internet sockets, communicating processes usually reside on different systems across the network. Similarly, vSockets allow guest virtual machines to communicate the host on which they reside.
The vSockets library supports both connection-oriented stream sockets like TCP, and connectionless datagram sockets like UDP. However, with vSockets, a virtual socket can have only two endpoints and unlike TCP sockets, the server cannot initiate a connection to the client.
VMware vSockets support data transfer among processes on the same system (interprocess communication). They also allow communication to processes on different systems, including ones running different versions and types of operating systems, and comprise a single protocol family.
Sockets require active processes, so communicating guest virtual machines must be running, not powered off.
VMware vSockets are available only at the user level. Kernel APIs are not supported.
Persistence of Sockets
VMware vSockets lose connection after suspend and resume of a virtual machine.
In VMware vSphere with ESX/ESXi hosts and vCenter Server, vSockets do not survive live migration with VMware vMotion™ from source to destination host. In vSphere with ESX/ESXi hosts, vSockets connections are dropped when a virtual machine is put into fault tolerance (FT) mode, and no new vSockets connections can be established while a virtual machine is in FT mode.
Socket Programming
If you have existing socket-based applications, only a few code changes are required for vSockets. If you do not have socket-based applications, you can easily find public-domain code on the Web. For example, Apache and Firefox, as shown in ESXi host with Stream vSockets and RabbitMQ, use stream sockets and are open source.
Repurposing a networking program to use vSockets requires minimal effort, because vSockets behave like traditional Internet sockets on a given platform. However, some socket options do not make sense for communication across the VMCI device, so they are silently ignored to promote program portability.
Modification is straightforward. You include a header file, change the protocol address family, and allocate a new data structure. Otherwise vSockets use the same API as Berkeley sockets or Windows sockets. See Porting Existing Socket Applications for a description of the modifications needed.