how to pass a python socket to a .dll?

I

inhahe

i'm trying to make a .dll that will let me use WSAPoll, which is a windows
sockets function, to mimic select.poll on a windows box. i cbb learning
python extensions, so i'm just going to use ctypes with a dll, so I hope
that it doesn't bring up a big performance issue. anyway, the problem is
that I want to use Python-created sockets with it, but WSAPoll requires
winsock2.h SOCKET objects.

so unless someone can tell me how to create/reference a windows socket
object using the winsock2 lib from just a file/socket descriptor (being that
this isn't a windows programming forum), i'm just asking how I could gain
access to the actual Windows socket associated with a Python socket that
Python for Windows has to store somewhere. even if I have to modify
socketmodule.c.

btw, i don't know much about this stuff, i hardly ever even program in c++,
so i hope anybody's not too cryptic :p
 
G

Gabriel Genellina

i'm trying to make a .dll that will let me use WSAPoll, which is a
windows
sockets function, to mimic select.poll on a windows box. i cbb learning
python extensions, so i'm just going to use ctypes with a dll, so I hope
that it doesn't bring up a big performance issue. anyway, the problem
is
that I want to use Python-created sockets with it, but WSAPoll requires
winsock2.h SOCKET objects.

Use the fileno() method to get the SOCKET handle.
If you're going to use ctypes anyway, why bother to write a DLL? Just
declare the required structures and functions using ctypes. Good luck!
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,143
Latest member
DewittMill
Top