Ticket #5295 (closed Bugs: Invalid)

Opened 2 months ago

Last modified 7 weeks ago

Error in example_button1.cpp

Reported by: jhsrennie Owned by:
Priority: 4 - Normal Milestone:
Component: Other (un-categorized) Version: SVN
Severity: Normal Keywords: event client
Cc: Platform: XBox
Revision:

Description

There is an error in the example_button1.cpp example event client (http://xbmc.org/trac/browser/branches/linuxport/XBMC/tools/EventClients)

The code uses the same CAddress (specifically the same sockaddr_in, more specifically the same port number) for both the host and peer. It needs to use a different port for the host. I suggest modifying the code to be something like:


CAddress my_addr(0); // Address => localhost on 9777
int sockfd = socket(PF_INET, SOCK_DGRAM, 0);
if (sockfd < 0)
{

printf("Error creating socket\n");
return -1;

}

my_addr.Bind(sockfd);

// Add this line to use a different CAddress for the peer

CAddress my_peer("192.168.128.128", 9777); // Address => localhost on 9777
CPacketHELO HeloPackage("Example Remote", ICON_PNG, "../../icons/bluetooth.png");
i = HeloPackage.Send(sockfd, my_peer);
printf("HeloPackage.Send returned %i\n", i);


I have not checked if other examples have the same problem.

Change History

in reply to: ↑ description   Changed 2 months ago by jhsrennie

Replying to jhsrennie:
Further investigation shows that the example_button1.cpp needs considerable modification to work, probably because of changes to the eventclient api during development of XBMC. I suggest this ticket be closed.

There is an error in the example_button1.cpp example event client (http://xbmc.org/trac/browser/branches/linuxport/XBMC/tools/EventClients)

The code uses the same CAddress (specifically the same sockaddr_in, more specifically the same port number) for both the host and peer. It needs to use a different port for the host. I suggest modifying the code to be something like:

----8<----
CAddress my_addr(0); // Address => localhost on 9777
int sockfd = socket(PF_INET, SOCK_DGRAM, 0);
if (sockfd < 0)
{
printf("Error creating socket\n");
return -1;
}

my_addr.Bind(sockfd);

// Add this line to use a different CAddress for the peer
CAddress my_peer("192.168.128.128", 9777); // Address => localhost on 9777
CPacketHELO HeloPackage("Example Remote", ICON_PNG, "../../icons/bluetooth.png");
i = HeloPackage.Send(sockfd, my_peer);
printf("HeloPackage.Send returned %i\n", i);
----8<----

I have not checked if other examples have the same problem.

  Changed 8 weeks ago by sho

  • milestone changed from Future / Pending to 9.04

  Changed 7 weeks ago by sho

  • status changed from new to closed
  • resolution set to Invalid
  • milestone deleted
Note: See TracTickets for help on using tickets.