changeset 2:b2c7c83a1dda

Accept 0.0.0.0 remote address for float mode
author ivo <ivo@UFO-Net.nl>
date Thu, 07 Oct 2010 16:01:41 +0200
parents 06be0fd16c60
children 27632fe319bd
files src/common.c
diffstat 1 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/common.c	Thu Oct 07 15:56:33 2010 +0200
+++ b/src/common.c	Thu Oct 07 16:01:41 2010 +0200
@@ -116,11 +116,15 @@
 		else if (!he->h_addr_list[0]) return errorexit("no address to connect to");
 		udpaddr.sin_family = he->h_addrtype;
 		udpaddr.sin_addr.s_addr = *((unsigned long*)he->h_addr_list[0]);
-		if (envval = getconf("REMOTE_PORT")) {
-			udpaddr.sin_port = htons(atoi(envval));
+		if (udpaddr.sin_addr.s_addr == 0) {
+			session->remote_float = 1;
+		} else {
+			if (envval = getconf("REMOTE_PORT")) {
+				udpaddr.sin_port = htons(atoi(envval));
+			}
+			if (connect(sfd, (struct sockaddr*)&udpaddr, sizeof(struct sockaddr_in))) return errorexitp("Could not connect socket");
+			session->remote_addr = udpaddr;
 		}
-		if (connect(sfd, (struct sockaddr*)&udpaddr, sizeof(struct sockaddr_in))) return errorexitp("Could not connect socket");
-		session->remote_addr = udpaddr;
 	}
 	session->fd_socket = sfd;
 	return sfd;