PDA

View Full Version : Prblem building the example_button1 event client


jhsrennie
2008-11-06, 12:56
I've been trying to build the example_button1 example event client as a preliminary to building a more sophisiticated client. I downloaded example_button1.cpp and xbmcclient.h from http://xbmc.org/trac/browser/branches/linuxport/XBMC/tools/EventClients and compiled it with:

cl -EHsc example_button1.cpp wsock32.lib
(Visual Studio 2005)

I add to add WSAStartip and WSACleanup, and I commented out the #include <sys/socket.h> to make it compile. Once I'd done this it built with no errors.

However when I run the executable it the "HeloPackage.Send" call fails i.e. returns 0. If I modify the line:

CAddress my_addr; // Address => localhost on 9777

to be

CAddress my_addr("192.168.128.128", 9777);

where 192.168.128.128 is my IP address, then HeloPackage.Send and the other .Send calls return 1, so they apparently work, but nothing gets sent. The example is supposed to send keystroke S then keystroke return. However nothing is received in XBMC.

I wrote a simple UDP listener and set it to listen on port 9777, but when I run the example no connection is received, so there's something wrong with the example.

Before I fire up the debugger to try and see what's happening is there anything obvious I've missed?

Also is the eventclient api documented anywhere? I was thinking of knocking up a quick test client in .Net to try and pin down the problem.

Thanks,

John Rennie

jhsrennie
2008-11-07, 19:20
Ok, I've worked out what's wrong. The example code is using the same CAddress (specifically the same sockaddr_in) for both the source and destination. Therefore it's trying to use the same port for both ends. Does this work on Unix? It certainly doesn't on Windows so i suspect it's a bug in the code.

Do I need to notify anyone?

John Rennie

jmarshall
2008-11-07, 23:43
Please open a ticket on trac about it, with your proposed changes, and we'll make sure the appropriate dev takes a look.

topfs2
2008-11-08, 10:53
... I add to add WSAStartip and WSACleanup, and I commented out the #include <sys/socket.h> to make it compile. Once I'd done this it built with no errors. ...
This is not needed, it should work ifdef _WIN32 though visual studio did that automaticly?


CAddress my_addr; // Address => localhost on 9777

to be

CAddress my_addr("192.168.128.128", 9777);

Cant say for windows but if you use the first code it uses port 9777 and addr_any which on linux it seems to bind to localhost (was a while since i cooked up this so my socket language is rusty)

But it might need changing to 127.0.0.1 to make it work stable on windows aswell.

Edit: It seems to be a bug concerning example_button1.cpp

jhsrennie
2008-11-10, 19:14
The example_button1.cpp example, and probably the other examples as well, are badly out of date. I'd guess the eventclient stuff in XBMC has changed during development and the examples need updating.

I have managed to get example_button1 working, but I'm not sure I fully understand how the api works so I'm reluctant to post my changes unless one of the developers is willing to look them over first.