Ticket #5295 (closed Bugs: Invalid)
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.
