Hi,
As using a blocking socket for a virtio device channel leads to be blocked if nobody has
opened the corresponding /dev/virtio-ports within the Guest , I tried to use a
non-blocking socket and
to check whether the socket is writeable via FD_ISSET().
I'm wondering why a virtio device channel is always seen as writeable by the Host
even if nobody has opened the corresponding /dev/virtio-ports within the Guest ?
res= connect(sock, (struct sockaddr *) &server, sizeof(struct sockaddr_un));
if (res < 0) {
perror("connecting stream socket");
close(sock);
return(1);
}
else
tv.tv_sec = 15;
tv.tv_usec = 0;
FD_ZERO(&myset);
FD_SET(sock, &myset);
if (select(sock+1, NULL, &myset, NULL, &tv) > 0) {
len = sizeof(int);
getsockopt(sock, SOL_SOCKET, SO_ERROR, (void*)(&result), &len);
if (result) {
fprintf(stderr, "Error in connection() %d - %s\n", result,
strerror(result));
return(1);
}
else
{
if(FD_ISSET(sock,&myset))
fprintf(stderr, "connection()is O.K. \n");
}
}
else {
fprintf(stderr, "Timeout or error() %d - %s\n", result,
strerror(result));
return(1);
}
Did I misunderstood something ?
Thanks for help.
J.P. Ribeauville
P: +33.(0).1.47.17.20.49
.
Puteaux 3 Etage 5 Bureau 4
jpribeauville@axway.com<mailto:jpribeauville@axway.com>
http://www.axway.com<http://www.axway.com/>
P Pensez à l'environnement avant d'imprimer.