Created
October 21, 2008 03:52
-
-
Save adammika/18245 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for (int i = 0; i < (int)peers.size(); i++) { | |
char* peer; | |
bzero((char *) &peer, sizeof(peer)); | |
peer = peers.at(i); | |
char* ip = strtok(peer," "); | |
char* port = strtok(NULL," "); | |
server_address.sin_port = htons(atoi(port)); | |
if (inet_pton(AF_INET,ip,&server_address.sin_addr) != 0) { | |
ostringstream xval; | |
xval << posx; | |
ostringstream yval; | |
yval << posy; | |
ostringstream frame; | |
frame << framestamp; | |
string message = "POSX " + xval.str() + "\nPOSY " + yval.str() + "\nCOLOR " + color + "\nNAME " + name + "\nFRAMESTAMP " + frame.str(); | |
if (sendto(socketfd,message.c_str(),sizeof(message),0,(struct sockaddr *)&server_address,sizeof(server_address)) == -1) { | |
cout << "Error sending UDP packet out" << endl; | |
} else cout << "Message sent!" << endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment