mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-30 08:34:16 +01:00
fail in main mode if udp socket not set
This commit is contained in:
parent
e79b0bd3eb
commit
991cc8f04c
1 changed files with 6 additions and 2 deletions
|
@ -1419,6 +1419,7 @@ enable_keepalive( int sock )
|
|||
static void
|
||||
maint_str_loop( int udpsock, const char* str )
|
||||
{
|
||||
logf( XW_LOGINFO, "%s()", __func__ );
|
||||
assert( -1 != udpsock );
|
||||
short len = strlen(str);
|
||||
unsigned char outbuf[2 + sizeof(len) + len];
|
||||
|
@ -1446,9 +1447,12 @@ maint_str_loop( int udpsock, const char* str )
|
|||
|
||||
ssize_t nRead = recvfrom( udpsock, buf, sizeof(buf), 0 /*flags*/,
|
||||
&saddr.addr, &fromlen );
|
||||
logf( XW_LOGINFO, "%s(); got %d bytes", __func__, nRead);
|
||||
|
||||
if ( 2 <= nRead && buf[0] == XWPDEV_PROTO_VERSION ) {
|
||||
if ( 1 <= nRead && buf[0] == XWPDEV_PROTO_VERSION ) {
|
||||
send_via_udp( udpsock, &saddr.addr, outbuf, sizeof(outbuf) );
|
||||
} else {
|
||||
logf( XW_LOGERROR, "unexpected data" );
|
||||
}
|
||||
}
|
||||
} // for
|
||||
|
@ -1644,7 +1648,7 @@ main( int argc, char** argv )
|
|||
}
|
||||
#endif
|
||||
|
||||
if ( 0 != udpport ) {
|
||||
if ( -1 != udpport ) {
|
||||
struct sockaddr_in saddr;
|
||||
g_udpsock = socket( AF_INET, SOCK_DGRAM, IPPROTO_UDP );
|
||||
saddr.sin_family = PF_INET;
|
||||
|
|
Loading…
Add table
Reference in a new issue