Quantcast
Channel: VMware Communities : All Content - All Communities
Viewing all articles
Browse latest Browse all 180329

How to use VMCI in VMware Workstation?

$
0
0

Dear All,

 

I meet a problem by using VMCI. when I run the code , it shows that "connect error: Connection reset by peer(errno: 104)"

 

here list the code of server side, which running on the host with windows 7.

.....

int afVMCI = VMCISock_GetAFValue();
if( (listenfd = socket(afVMCI, SOCK_STREAM, 0)) == -1 )

{
printf("create socket error: %s(errno: %d)\n",strerror(errno),errno);
exit(0);
}

memset(&servaddr, 0, sizeof(servaddr));
servaddr.svm_family = afVMCI;
servaddr.svm_cid = VMADDR_CID_ANY;
servaddr.svm_port = 2000;

if( bind(listenfd, (struct sockaddr*)&servaddr, sizeof(servaddr)) == -1)

{
printf("bind socket error: %s(errno: %d)\n",strerror(errno),errno);
exit(0);
}

if( listen(listenfd, 10) == -1)

{
printf("listen socket error: %s(errno: %d)\n",strerror(errno),errno);
exit(0);
}


printf("======waiting for client's request======\n");


while(1)
{
struct sockaddr_vm their_addr={0};
socklen_t their_addr_len = sizeof (their_addr);

if ((connfd = accept(listenfd, (struct sockaddr *) &their_addr, &their_addr_len)) == -1)

{
printf("accept socket error: %s(errno: %d)",strerror(errno),errno);
continue;

}

......

}

 

 

 

here list the code of client side, which running on the vm with linux.

 

int afVMCI = VMCISock_GetAFValue();

if( (sockfd = socket(afVMCI, SOCK_STREAM, 0)) < 0)

{
printf("create socket error: %s(errno: %d)\n", strerror(errno),errno);
exit(0);
}

memset(&servaddr, 0, sizeof(servaddr));

 

servaddr.svm_family = afVMCI;
servaddr.svm_cid = VMCISock_GetLocalCID();
servaddr.svm_port = 2000;


if( connect(sockfd, (struct sockaddr*)&servaddr, sizeof(servaddr)) < 0)

{
printf("connect error: %s(errno: %d)\n",strerror(errno),errno);
exit(0);
}

 

Thank you and Best regards


Viewing all articles
Browse latest Browse all 180329

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>