version 1.2 | | version 1.3 |
---|
| | |
/* | | /* |
* static char *rcsid_metaserver_c = | | * static char *rcsid_metaserver_c = |
* "$Id: metaserver.c,v 1.2 2000/11/17 05:07:45 cvs Exp $"; | | * "$Id: metaserver.c,v 1.3 2000/11/18 04:27:49 cvs Exp $"; |
*/ | | */ |
| | |
/* | | /* |
| | |
#include <version.h> | | #include <version.h> |
#include <patchlevel.h> | | #include <patchlevel.h> |
| | |
#ifndef MSG_DONTWAIT | | |
#define MSG_DONTWAIT O_NONBLOCK | | |
#endif | | |
| | |
static int metafd=-1; | | static int metafd=-1; |
static struct sockaddr_in sock; | | static struct sockaddr_in sock; |
| | |
| | |
} | | } |
memcpy(&sock.sin_addr, hostbn->h_addr, hostbn->h_length); | | memcpy(&sock.sin_addr, hostbn->h_addr, hostbn->h_length); |
} | | } |
| | fcntl(metafd, F_SETFL, O_NONBLOCK); |
if ((metafd=socket(AF_INET, SOCK_DGRAM, 0))==-1) { | | if ((metafd=socket(AF_INET, SOCK_DGRAM, 0))==-1) { |
LOG(llevDebug,"metaserver_init: Unable to create socket, err %d\n", errno); | | LOG(llevDebug,"metaserver_init: Unable to create socket, err %d\n", errno); |
return; | | return; |
| | |
sock.sin_port = htons(settings.meta_port); | | sock.sin_port = htons(settings.meta_port); |
if (connect(metafd, &sock, sizeof(sock))<0) { | | if (connect(metafd, &sock, sizeof(sock))<0) { |
LOG(llevDebug,"metaserver_init: Unable to connect to metaserver, err %d\n", errno); | | LOG(llevDebug,"metaserver_init: Unable to connect to metaserver, err %d\n", errno); |
close(metafd); | | |
metafd=-1; | | |
return; | | |
} | | } |
/* No hostname specified, so lets try to figure one out */ | | /* No hostname specified, so lets try to figure one out */ |
if (settings.meta_host[0]==0) { | | if (settings.meta_host[0]==0) { |
| | |
| | |
sprintf(data,"%s|%d|%s%s|%s", settings.meta_host, num_players, VERSION, PATCH, | | sprintf(data,"%s|%d|%s%s|%s", settings.meta_host, num_players, VERSION, PATCH, |
settings.meta_comment); | | settings.meta_comment); |
if (sendto(metafd, data, strlen(data), MSG_DONTWAIT, &sock, sizeof(sock))<0) { | | if (sendto(metafd, data, strlen(data), 0, &sock, sizeof(sock))<0) { |
LOG(llevDebug,"metaserver_update: sendto failed, err = %d\n", errno); | | LOG(llevDebug,"metaserver_update: sendto failed, err = %d\n", errno); |
} | | } |
} | | } |