Last active
November 29, 2015 09:52
-
-
Save schaeferpp/dc7e1698c6294776d084 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
int | |
main(int argc, | |
char *argv[]) | |
{ | |
struct gameinfo peer; | |
int start; | |
heartbeat_message *msg; | |
if (argc == 4) | |
{ | |
start = 0; | |
} | |
else if (argc == 5) | |
{ | |
start = 1; | |
} | |
else | |
{ | |
usage(); | |
return 1; | |
} | |
init_cblib(); | |
own_port = (uint16_t) atoi(argv[1]); | |
memset(&peer, 0, sizeof (peer)); | |
peer.hostname = argv[2]; | |
peer.service = argv[3]; | |
game_bind(&peer); | |
if (!peer_connect (&peer)) | |
{ | |
fprintf (stderr, "Could not connect to peer, exiting\n"); | |
exit(1); | |
} | |
if (start) | |
{ | |
msg = heartbeat_message_new (); | |
Send(peer.fd, msg, msg->length, 0); | |
Send(peer.fd, msg, msg->length, 0); | |
Send(peer.fd, msg, msg->length, 0); | |
Send(peer.fd, msg, msg->length, 0); | |
Send(peer.fd, msg, msg->length, 0); | |
Send(peer.fd, msg, msg->length, 0); | |
peer.last_hb = msg; | |
} | |
printf("register callback for fd %d\n", peer.fd); | |
/* len = Recvfrom(peer.fd, (void *) buf, sizeof(buf), 0, (struct sockaddr *) &client_addr, &addr_len); */ | |
/* len = Recv(peer.fd, (void *) buf, sizeof(buf), 0); */ | |
/* printf ("%zd\n", len); */ | |
register_fd_callback (peer.fd, peer_data_available, &peer); | |
handle_events(); | |
free (peer.address); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment