Python: Socket set source port number

Posted by beratch on Stack Overflow See other posts from Stack Overflow or by beratch
Published on 2010-04-22T20:25:24Z Indexed on 2010/04/22 20:33 UTC
Read the original article Hit count: 810

Filed under:
|
|
|
|

Hi all,

I'd like to send a specific UDP broadcast packet.. unfortunatly i need to send the udp packet from a very specific port for all packet I send.

Let say I broadcast via UDP "BLABLAH", the server will only answer if my incoming packet source port was 1444, if not the packet is discarded.

My broadcast socket setup look like this :

s = socket(AF_INET,SOCK_DGRAM)

s.setsockopt(SOL_SOCKET, SO_BROADCAST, 1)

How can i do that (set the source port) in python ?

Thanks!

© Stack Overflow or respective owner

Related posts about python

Related posts about socket