Martin Glas <[EMAIL PROTECTED]>:

> I have a problem with openssl-0.9.[0123] on WinNT 4.0 SP3.
> I compiled it using VC-6 (and also mingw32) [...]  cannot connect to
> a SSL server properly (neither using 'openssl s_client -connect...'
> nor doing a request from the Net:SSLeay package). I get the
> following error:

> (...)
> connect: Bad file descriptor
> connect: errno = 10061
> error in s_client
> 
> I tried it on Linux and Solaris where everything worked
> well. I understand that a 'socket' on WinNT is something
> different than on UNIX machines. Could this be the problem?

I have no idea.  The relevant code is in apps/s_socket.c, namely

int init_client_ip(int *sock, unsigned char ip[4], int port)
        {
        unsigned long addr;
        struct sockaddr_in them;
        int s,i;

        if (!sock_init()) return(0);

        memset((char *)&them,0,sizeof(them));
        them.sin_family=AF_INET;
        them.sin_port=htons((unsigned short)port);
        addr=(unsigned long)
                ((unsigned long)ip[0]<<24L)|
                ((unsigned long)ip[1]<<16L)|
                ((unsigned long)ip[2]<< 8L)|
                ((unsigned long)ip[3]);
        them.sin_addr.s_addr=htonl(addr);

        s=socket(AF_INET,SOCK_STREAM,SOCKET_PROTOCOL);
        if (s == INVALID_SOCKET) { perror("socket"); return(0); }

        i=0;
        i=setsockopt(s,SOL_SOCKET,SO_KEEPALIVE,(char *)&i,sizeof(i));
        if (i < 0) { perror("keepalive"); return(0); }

        if (connect(s,(struct sockaddr *)&them,sizeof(them)) == -1)
                { close(s); perror("connect"); return(0); }
        *sock=s;
        return(1);
        }

While setsockopt works, connect fails (the "connect: Bad file
descriptor" error message).  Both use the same identifier (s), so it
seems unlikely that the difference between sockets and proper files is
responsible for the error.  Do you have non-standard header files
installed on your system, or non-standard libraries?
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to