5

i want to write a program using multi-threading, raw sockets, to scan the ports in python i have a C code for injection of raw socket. i want to perform a ACK scan so need a raw socket.

So please help me.

thank you

AJINKYA
  • 741
  • 2
  • 9
  • 20
  • Step 1. Search. Step 2. Read. Hint: http://stackoverflow.com/questions/tagged/python+c Also, this: http://stackoverflow.com/questions/tagged/python%20c%2b%2b – S.Lott Oct 19 '10 at 13:05

2 Answers2

4

Please check out Cython. It makes it very easy to wrap C code.

This is adapted from the documentation on calling external C functions:

cdef extern from "math.h":
    double sin(double)

def pysin(x):
    return sin(x)

You could then call pysin from the compiled module like a normal Python module.

Ryan Ginstrom
  • 13,915
  • 5
  • 45
  • 60
0

I would definitely go with boost.python, which provides even cleaner wrappers. If you dislike the idea of using C++, then Cython is a good alternative.

hannes
  • 966
  • 9
  • 13