Bonjour'ing the PMS

Port 32400?
Hello!

I started a Little App to learn about the PLEX infrastucture.
Think about "Hello World" in Plex :-)

In short, it looks like this:
* look up Plex Media Server on Bonjour...
LOOP
* request "http://
* receive XML and decode.
* receive user input: move up/down in folder hirachy
UNTIL VIDEO FILE
* call video player

My problem: Bonjour returns the PMS IP Address including a Port. This port (typically 36990) does not work at all. Using 32400 - as seen in the logs - does the trick.
Question: Why do I get the "wrong" Port?

Thanks for your help!
Berni

Not sure - my boujour code (based/borrowed/stolen from pyBonjour) returns 32400 as the port number. You are requesting just the Plex server aren’t you (_plexmediasvr._tcp), this isn’t the port of another service getting mixed up?



Yeah... you are right: I looked up "_plexmediasvr._tcp". How do I satisfy Bonjour to bring back the correct 32400 address? What information do I have to add? And where?

This is the call I used for DNSServiceBrowse:

<br />
	/*<br />
	 DNSServiceErrorType DNSServiceBrowse ( <br />
	 DNSServiceRef *sdRef, <br />
	 DNSServiceFlags flags, <br />
	 uint32_t interfaceIndex, <br />
	 const char *regtype, <br />
	 const char *domain, /.* may be NULL *./<br />
	 DNSServiceBrowseReply callBack, <br />
	 void *context /.* may be NULL *./<br />
	 );  <br />
	 */<br />
	DNSErr = DNSServiceBrowse(<br />
			&sdRef,<br />
			0,<br />
			0,<br />
			"_plexmediasvr._tcp", <br />
			NULL,<br />
			DNSCallbackBrowse,<br />
			NULL<br />
			);<br />




Thanks a lot for your help!
Berni

Hippojay…



I looked deeper into your PleXBMC code to figure out your “Bonjour” technique.

Running the latest version of XMBC (“darma”?) prevents using Bonjour. It complains and wants “eden” at most.

Why is this feature deactivated with the current release?



Thanks,

Berni



Sorry I didn't reply back - thought you were looking for a C solution.

The only reason bonjour doesn;t work with XBMC 10.1 is a library dependancy and python version issue. You need the cTypes library, which doesn't come as standard in python 2.4 (which 10.1 uses). However XBMX eden uses 2.6 (and potentially any system version of python too), which includes ctypes. As I want me plugin to work on all platforms, I wouldn have had to include seperate code for win, osx, linux, ios, etc - so only making this work on XBMC eden is the only real option.


Also, my bonjour technoque may not be the best, but it was the best I could understand from the example code (still not 100% on how a callback is made)..


I got it...
The thing is, I just "casted" the Port to UINT16, which should be enough to hold the information.
But I misunderstood Apple heritage, switching from Motorola to Intel - both of which use a different byte layout: big vs. little endian.

Translating the decimal number shows
36990 = 0x907E or (binary) 10010000 01111110
32400 = 0x7E90 or (binary) 01111110 10010000

I "only" have to switch the bytes... I guess using the datatype correctly will fix that :-)

EDIT: Hm. According to the dns_sd.h documentation "DNSServiceResolveReply" returns a uint16. Looks like Bonjour really needs some manual tweaking on Intel.

EDIT: ...looks like it has nothing to do with Motorola/Intel processors. Online it is called "network byte order", used in the lower level APIs.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.