VMware

This Question is Possibly Answered

1 "correct" answer available (10 pts) 2 "helpful" answers available (6 pts)
3 Replies Last post: Jul 22, 2009 11:03 AM by souminathanvm…  

VMCI problem posted: May 20, 2009 4:51 PM

Click to view teflonpenguin's profile Lurker 2 posts since
May 11, 2009

When compiling and running the following code I get the error shown below.

$ g++ -g -o client client_udp.cpp

$ client 172.16.7.173 9999 4096
VMCIsockAddressFamily=34
Attempt to send 4096 bytes.
sendto() error: Invalid argument.

Note the address family of 34 in /usr/include/linux/socket.h conflicts with AF_MAX.

This was run on a Pentium 4 machine running Fedora 10 with VMPlayer 2.5.2 (build 156735)

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include </usr/lib/vmware/include/vmci/vmci_sockets.h>

#define MAX_LENGTH_UDP 65536


int
main(int argc, char *argv[])
{
int sockfd, n, port, packetSize;
unsigned clientLength;
unsigned sendlength;
char bufferMAX_LENGTH_UDP;

if (argc != 4) {
printf("Usage: %s server port packetsize\n",argv[0]);
exit(-1);
}
port = atoi(argv[2]);
sendlength = atoi(argv[3]);

int VMCIsockAddressFamily = VMCISock_GetAFValue();
sockfd = socket(VMCIsockAddressFamily, SOCK_DGRAM, 0);
printf("VMCIsockAddressFamily=%d\n",VMCIsockAddressFamily);

if (sockfd < 0) {
printf("Socket error: VMCIsockAddressFamily=%d %s\n",VMCIsockAddressFamily,strerror(errno));
exit(-1);
}


struct sockaddr_vm server;
clientLength = sizeof (struct sockaddr_vm) ;
memset(&server,0,sizeof(server));
server.svm_family = VMCIsockAddressFamily;
server.svm_cid = 2;
server.svm_port = 9999;

fprintf(stdout, "Attempt to send %d bytes.\n", sendlength);

if (( n = sendto(sockfd, buffer, sendlength, 0, (struct sockaddr *) & server, clientLength)) < 0) {
printf("sendto() error: %s\n",strerror(errno));

}

return 0;
}

Re: VMCI problem

1. May 21, 2009 9:26 AM in response to: teflonpenguin
Click to view svaerke's profile Novice 9 posts since
Jul 11, 2008

Hi,

Are you running a server on the host that is ready to receive the datagram on the specified address? It has been reported elsewhere in this forum that using sendto to a non-existing socket will make sendto return the Invalid argument error.

Thanks,

Jorgen

Re: VMCI problem

2. Jun 15, 2009 10:47 AM in response to: svaerke
Click to view timwi's profile Lurker 1 posts since
Jun 11, 2009
Edit: updated after running a test

What I think teflonpenguin is trying to say is that the Address Family of VMCI is coming back as 34 which is the # for AF_MAX (of all things to use). Looking into the vmci_sockets.h, it looks like VMCI is letting the OS return a # on demand. I tried the example above with a server on the other side and it worked. (Windows Xp host/Ubuntu guest). Not sure what the outcome would be the other way around (linux host).

Re: VMCI problem

3. Jul 22, 2009 11:03 AM in response to: timwi
Click to view souminathanvmware's profile Lurker 4 posts since
Jul 22, 2009

Hi Guys,

I am trying to run a udp server in CentOS 5.3 (my host) and running a udp client socket in Ubuntu 9.04.

I am not able to communicate with my server. I always get a "send" or "sendto" invalid argument error.

Have anyone tried this socket on both linux host and linux client and have succeeded. If so could you provide us a sample of their code.

Thanks

Swami

Developer Social Media

Communities