Discovery IP in connection

D

Djames Suhanko

Hello,all!
I wrote a little programa that listening UDP packets. A can receive
the messages, but I can't see the the origin IP.
How can I to get the remote IP address in connection?

My source:

#!/usr/bin/env python
import socket
mySocket = socket.socket ( socket.AF_INET, socket.SOCK_DGRAM )
mySocket.bind ( ( '', 514 ) )

data, addr = mySocket.recvfrom(100)
print data
 
R

Roy Smith

Djames Suhanko said:
Hello,all!
I wrote a little programa that listening UDP packets. A can receive
the messages, but I can't see the the origin IP.
How can I to get the remote IP address in connection?

My source:

#!/usr/bin/env python
import socket
mySocket = socket.socket ( socket.AF_INET, socket.SOCK_DGRAM )
mySocket.bind ( ( '', 514 ) )

data, addr = mySocket.recvfrom(100)
print data

What happens when you print addr?
 
P

Piet van Oostrum

Djames Suhanko said:
DS> Hello,all!
DS> I wrote a little programa that listening UDP packets. A can receive
DS> the messages, but I can't see the the origin IP.
DS> How can I to get the remote IP address in connection?

What do you think the addr is for in
data, addr = mySocket.recvfrom(100)?
DS> My source:
 
D

Djames Suhanko

Thanks, all!
I didn't tried to print addr. :-(
sorry all. I'm learning python yet.
Thanks again !
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top