Because this is a connectionless protocol, you pass the socket address structure their_addr as a parameter to the sendto() call.
struct sockaddr_vm their_addr = {0}; their_addr.svm_family = afVMCI; their_addr.svm_cid = SERVER_CID; their_addr.svm_port = SERVER_PORT; if ((numbytes = sendto(sockfd, buf, BUFIZE, 0, (struct sockaddr *) &their_addr, sizeof their_addr)) == -1) { perror("sendto"); goto close; }
The sockaddr_vm structure contains an element for the CID to specify the virtual machine. For the client making a connection, the VMCISock_GetLocalCID() function returns the CID of the virtual machine.
The port number is arbitrary, although the server (listener) and client (connector) must use the same number, which must designate a port not already in use. Only privileged processes can use ports < 1024.