ImportError: DLL load failed

Discussion in 'Python' started by Ajay, Sep 26, 2004.

  1. Ajay

    Ajay Guest

    hi!

    I wrote a simple C code to work with OpenSSL and it builds fine.
    however when i import it, i get an error
    ImportError: DLL load failed. The specified module could not be found.

    the file is in Python/Lib directory.

    the code is below.

    thanks

    #include <Python.h>
    #include "openssl/bio.h"
    #include "openssl/ssl.h"
    #include "openssl/err.h"

    static PyObject * start(PyObject *self, PyObject *args)
    {
    int x;
    BIO * bio;
    char buf[1024];
    int len = 512;
    SSL_load_error_strings();
    ERR_load_BIO_strings();
    OpenSSL_add_all_algorithms();
    bio = BIO_new_connect("www.ibm.com:80");
    if(bio==NULL)
    {
    //handle error
    x = -5;
    }
    if(BIO_do_connect(bio) <= 0)
    {
    //handle failed connection
    x = -4;
    }
    x = BIO_read(bio, buf, len);
    if(x == 0)
    {
    //handle closed connection
    x = -3;
    }
    else if(x<0)
    {
    if(! BIO_should_retry(bio))
    {
    //handle failed read
    x = -2;
    }
    //do something to handle the retry
    }
    return Py_BuildValue("i", x);
    }

    static PyMethodDef testSSLMethods[] = {
    {"start", start, METH_VARARGS, "start and test SSL."},
    {NULL, NULL, 0, NULL}
    };

    PyMODINIT_FUNC
    inittestSSL(void)
    {
    (void) Py_InitModule("testSSL", testSSLMethods);
    }





    ----------------------------------------------------------------
    This message was sent using IMP, the Internet Messaging Program.
    Ajay, Sep 26, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andrew MacIntyre

    Re: ImportError: DLL load failed

    Andrew MacIntyre, Jun 28, 2008, in forum: Python
    Replies:
    0
    Views:
    600
    Andrew MacIntyre
    Jun 28, 2008
  2. Chris Cormie
    Replies:
    11
    Views:
    12,277
    Chris Cormie
    Feb 24, 2009
  3. Richard Whidden

    pythoncom -- ImportError: DLL load failed

    Richard Whidden, Apr 24, 2009, in forum: Python
    Replies:
    3
    Views:
    1,752
    Mark Hammond
    Apr 25, 2009
  4. André
    Replies:
    4
    Views:
    6,032
    thompjs
    Jan 24, 2011
  5. Albert-Jan Roskam
    Replies:
    2
    Views:
    80
    Chris Angelico
    Nov 25, 2013
Loading...

Share This Page