LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 04-13-2009, 07:43 PM   #1
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Colombia
Distribution: Kubuntu, Debian, Knoppix
Posts: 1,982
Blog Entries: 1

Rep: Reputation: 83
Exclamation zeroconf (python): client doesn't get to see the server


Hi!

I'm doing this little experiment to publish a network service with zeroconf. Right now I'm running both the client and the server on localhost (and perhaps that's the problem!), but the fact is that the client doesn't get to see the service that the server is publishing.

Here's the relevant code.
Server:
Code:
import Zeroconf

svc1 = Zeroconf.ServiceInfo('_durus._tcp.local.',
                              'Database 1._durus._tcp.local.',
                              address = socket.inet_aton(SERVER_ADDRESS),
                              port = SOCKET_PORT,
                              weight = 0, priority=0,
                              properties = {'description':
                                            'FLISoL Installation Finished Registration'}
                             )
Zeroconf.Zeroconf().registerService(svc1)
SERVER_ADDRESS = '127.0.0.1' in this example, also SOCKET_PORT = 9000. WHen I start the server, I see traffic on the loopback:
Code:
19:35:48.972352 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0 [b2&3=0x400] [1n] PTR (QM)? _http._tcp.local. (80)
19:35:49.148143 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0 [b2&3=0x400] [1n] PTR (QM)? _http._tcp.local. (80)
19:35:49.323062 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0 [b2&3=0x400] [1n] PTR (QM)? _http._tcp.local. (80)
19:35:49.323519 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0*- [0q] 4/0/0 PTR[|domain]
19:35:49.549251 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0*- [0q] 4/0/0 PTR[|domain]
19:35:49.774401 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0*- [0q] 4/0/0 PTR[|domain]
19:35:49.975129 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0 [3q] SRV (QM)? ZOE._http._tcp.local. TXT (QM)? ZOE._http._tcp.local.[|domain]
19:35:50.175707 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0 [3q] SRV (QM)? ZOE._http._tcp.local. TXT (QM)? ZOE._http._tcp.local.[|domain]
19:35:50.576289 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0 [3q] SRV (QM)? ZOE._http._tcp.local. TXT (QM)? ZOE._http._tcp.local.[|domain]
19:35:51.376912 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0 [3q] SRV (QM)? ZOE._http._tcp.local. TXT (QM)? ZOE._http._tcp.local.[|domain]
19:35:52.975873 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0 [3q][|domain]
19:35:53.176473 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0 [3q][|domain]
19:35:53.577075 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0 [3q][|domain]
19:35:54.377646 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0 [3q][|domain]
19:35:55.776465 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0*- [0q] 4/0/0 PTR[|domain]
19:35:55.902193 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0*- [0q] 4/0/0 PTR[|domain]
19:35:56.027232 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0*- [0q] 4/0/0 PTR[|domain]
19:35:56.031536 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0 [b2&3=0x400] [1n] PTR (QM)? _durus._tcp.local. (77)
19:35:56.207322 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0 [b2&3=0x400] [1n] PTR (QM)? _durus._tcp.local. (77)
19:35:56.383018 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0 [b2&3=0x400] [1n] PTR (QM)? _durus._tcp.local. (77)
19:35:56.383512 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0*- [0q] 4/0/0 PTR[|domain]
19:35:56.609262 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0*- [0q] 4/0/0 PTR[|domain]
19:35:56.834367 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0*- [0q] 4/0/0 PTR[|domain]
On the client:
Code:
exec open('Zeroconf.py').read()
print "Imported"

import Zeroconf

class MyListener(object):
    def removeService(self, server, type, name):
        print "Service", repr(name), "removed"

    def addService(self, server, type, name):
        global SERVER_ADDRESS
        global SERVICE_PORT
        print "Service", repr(name), "added"
        # Request more information about the service
        info = server.getServiceInfo(type, name)
        SERVER_ADDRESS = server.address
        SERVICE_PORT = server.port
        print 'Additional info:', info

server = Zeroconf.Zeroconf()
listener = MyListener()
browser = Zeroconf.ServiceBrowser(server, "_durus._tcp.local.", listener)

# will only wait for 5 seconds
import time
print "Waiting to locate service with Zeroconf"
time.sleep(5)

if SERVER_ADDRESS == 0 or SERVICE_PORT == 0:
    print "Couldn't find registration service"
    exit(-1)
When I start the client, I see this traffic:
Code:
19:42:38.153906 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0 [b2&3=0x400] [1n] PTR (QM)? _http._tcp.local. (80)
19:42:38.329811 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0 [b2&3=0x400] [1n] PTR (QM)? _http._tcp.local. (80)
19:42:38.504777 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0 [b2&3=0x400] [1n] PTR (QM)? _http._tcp.local. (80)
19:42:38.505561 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0*- [0q] 4/0/0 PTR[|domain]
19:42:38.731442 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0*- [0q] 4/0/0 PTR[|domain]
19:42:38.956632 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0*- [0q] 4/0/0 PTR[|domain]
19:42:39.158126 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0 [3q] SRV (QM)? ZOE._http._tcp.local. TXT (QM)? ZOE._http._tcp.local.[|domain]
19:42:39.358721 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0 [3q] SRV (QM)? ZOE._http._tcp.local. TXT (QM)? ZOE._http._tcp.local.[|domain]
19:42:39.759287 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0 [3q] SRV (QM)? ZOE._http._tcp.local. TXT (QM)? ZOE._http._tcp.local.[|domain]
19:42:40.559872 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0 [3q] SRV (QM)? ZOE._http._tcp.local. TXT (QM)? ZOE._http._tcp.local.[|domain]
19:42:42.158797 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0 [3q][|domain]
19:42:42.359377 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0 [3q][|domain]
19:42:42.759965 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0 [3q][|domain]
19:42:43.561666 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0 [3q][|domain]
19:42:44.959447 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0*- [0q] 4/0/0 PTR[|domain]
19:42:45.085191 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0*- [0q] 4/0/0 PTR[|domain]
19:42:45.210185 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0*- [0q] 4/0/0 PTR[|domain]
19:42:45.214745 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0 PTR (QM)? _durus._tcp.local. (35)
19:42:45.714968 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0 PTR (QM)? _durus._tcp.local. (35)
19:42:46.715124 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0 PTR (QM)? _durus._tcp.local. (35)
19:42:48.715284 IP 127.0.1.1.5353 > 224.0.0.251.5353: 0 PTR (QM)? _durus._tcp.local. (35)
So... what am I missing? Thanks in advance
 
  


Reply

Tags
python, zeroconf


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
zeroconf:/ Not working :( Cyhaxor Linux - Newbie 8 08-27-2007 06:38 PM
can't build BitTorrent client; Python dependencies? belliott4488 Fedora 5 02-10-2007 08:49 AM
be careful of zeroconf mp55 Debian 3 02-16-2006 01:13 PM
stubborn zeroconf BasK Mandriva 14 01-14-2004 04:26 PM
Refresh client user list at autentication client/server network. robertoneto123 Linux - Networking 0 11-11-2003 10:38 AM


All times are GMT -5. The time now is 10:24 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration