Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Discovery IP in connection

0 views
Skip to first unread message

Djames Suhanko

unread,
Jul 27, 2009, 4:25:32 PM7/27/09
to pytho...@python.org
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

--
Djames Suhanko
LinuxUser 158.760

Roy Smith

unread,
Jul 27, 2009, 7:21:43 PM7/27/09
to
In article <mailman.3797.1248726...@python.org>,
Djames Suhanko <djames....@gmail.com> wrote:

What happens when you print addr?

Piet van Oostrum

unread,
Jul 27, 2009, 7:23:13 PM7/27/09
to
>>>>> Djames Suhanko <djames....@gmail.com> (DS) wrote:

>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:

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

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

--
Piet van Oostrum <pi...@cs.uu.nl>
URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
Private email: pi...@vanoostrum.org

Djames Suhanko

unread,
Jul 28, 2009, 3:27:24 PM7/28/09
to Piet van Oostrum, pytho...@python.org
Thanks, all!
I didn't tried to print addr. :-(
sorry all. I'm learning python yet.
Thanks again !

> --
> http://mail.python.org/mailman/listinfo/python-list

0 new messages