# HG changeset patch # User reimar # Date 1283971347 0 # Node ID b8514776c9ec51d693beac39ffc4fb3873fc26af # Parent 3133252ce3faaaa2260d493d442667de84c50692 Handle failures to create a socket. diff -r 3133252ce3fa -r b8514776c9ec udp_sync.c --- a/udp_sync.c Wed Sep 08 18:37:55 2010 +0000 +++ b/udp_sync.c Wed Sep 08 18:42:27 2010 +0000 @@ -74,6 +74,7 @@ // gets a datagram from the master with or without blocking. updates // master_position if successful. if the master has exited, returns 1. +// returns -1 on error. // otherwise, returns 0. int get_udp(int blocking, float *master_position) { @@ -93,6 +94,8 @@ done_init_yet = 1; sockfd = socket(AF_INET, SOCK_DGRAM, 0); + if (sockfd == -1) + return -1; servaddr.sin_family = AF_INET; servaddr.sin_addr.s_addr = htonl(INADDR_ANY); @@ -144,6 +147,8 @@ done_init_yet = 1; sockfd = socket(AF_INET, SOCK_DGRAM, 0); + if (sockfd == -1) + exit_player(EXIT_ERROR); // Enable broadcast setsockopt(sockfd, SOL_SOCKET, SO_BROADCAST, &one, sizeof(one));