diff -r camserv-0.5.0/camserv/main_loop.c camserv-0.5.0-ipv6/camserv/main_loop.c
375c375,376
<   int cfg_listen_port, highest_fd, picture_client_ready;
---
>   char *cfg_listen_port;
>   int highest_fd, picture_client_ready;
382,384c383,385
<   cfg_listen_port = camconfig_query_def_int( ccfg, SEC_SOCKET, 
< 					     "listen_port",
< 					     CAMCONFIG_DEF_LISTEN_PORT );
---
>   cfg_listen_port = camconfig_query_str( ccfg, SEC_SOCKET, 
> 					     "listen_port");
>   if (cfg_listen_port == NULL) cfg_listen_port = CAMCONFIG_DEF_LISTEN_PORT;
398c399
<       camserv_log( MODNAME, "Error setting up socket on port \"%d\".  Exiting",
---
>       camserv_log( MODNAME, "Error setting up socket on port \"%s\".  Exiting",
diff -r camserv-0.5.0/common/socket.c camserv-0.5.0-ipv6/common/socket.c
35a36
>   int	family;					// Internet Protocol family (AF_INET / AF_INET6 etc)
79d79
< 
117,149d116
< /*
<  * socket_resolv_hostname:  Resolve a string hostname to a internet sockaddr
<  *                          structure
<  *
<  * Arguments:               hname = Hostname to resolve.
<  *                          sin   = Sockaddr struct to place resolved host
<  *
<  * Return values:           Returns -1 on failure, 0 on succes.
<  */
< 
< static
< int socket_resolv_hostname( const char *hname, struct sockaddr_in *sin ){
<   struct hostent *hostp;
<   unsigned long addr;
< 
<   addr = inet_addr( hname );
< #ifdef INADDR_NONE
<   if( addr != INADDR_NONE )
<     memcpy( &sin->sin_addr, &addr, sizeof( addr ));
< #else
<   if (addr != (in_addr_t)-1)
<     memcpy( &sin->sin_addr, &addr, sizeof( addr ));
< #endif
<   else {
<     hostp = gethostbyname( hname );
<     if( hostp == NULL )
<       return -1;
<     else
<       memcpy( &sin->sin_addr, hostp->h_addr, hostp->h_length );
<   }
< 
<   return 0;
< }
207,256c174,237
< Socket *socket_serve_tcp( const char *hname, int port, int backlog ){
<   Socket *sockres;
<   struct sockaddr_in sin;
<   int val;
< 
<   if( (sockres = socket_new()) == NULL )
<     return NULL;
< 
<   sockres->port = port;
< 
<   if( (sockres->fd = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP )) < 0 ){
<     perror( "socket()" );
<     socket_dest( sockres );
<     return NULL;
<   }
< 
<   sin.sin_family = AF_INET;
<   sin.sin_port   = htons( port );
<   
<   if( hname == NULL ) {
<     sin.sin_addr.s_addr = INADDR_ANY;
<     socket_set_remote_name( sockres, "Any Host" );
<   } else {
<     socket_set_remote_name( sockres, hname );
<     if( socket_resolv_hostname( hname, &sin ) == -1 ) {
<       socket_dest( sockres );
<       return NULL;
<     }
<   }
< 
<   val = 1;
<   if( setsockopt( sockres->fd,SOL_SOCKET,SO_REUSEADDR, &val, sizeof( int )) <0)
<     perror( "setsockopt()" );
<   val = 1;
<   if( setsockopt( sockres->fd,SOL_SOCKET,SO_KEEPALIVE, &val, sizeof( int )) <0)
<     perror( "setsockopt()" );
< 
<   if( bind( sockres->fd, (struct sockaddr *)&sin, sizeof( sin )) < 0 ) {
<     perror( "bind()" );
<     socket_dest( sockres );
<     return NULL;
<   }
< 
<   if( listen( sockres->fd, backlog ) < 0 ) {
<     perror( "close()" );
<     socket_dest( sockres );
<     return NULL;
<   }
< 
<   return sockres;
---
> Socket *socket_serve_tcp( const char *hname, char *port, int backlog )
> {
> 	Socket		*sockres;
> 	struct addrinfo	hints;
> 	struct addrinfo	*res;
> 	int		error, val;
> 
> 	if ((sockres = socket_new()) == NULL)
> 		return NULL;
> 
> 	sockres->port = atoi(port);
> 	
> 	memset(&hints, 0, sizeof(hints));
> 	/* set-up hints structure */
> 	hints.ai_family = PF_UNSPEC;
> 	hints.ai_flags = AI_PASSIVE;
> 	hints.ai_socktype = SOCK_STREAM;
> 	error = getaddrinfo(hname, port, &hints, &res);
> 	if (error)
> 	{
> 		perror(gai_strerror(error));
> 		return 0;
> 	}
> 	sockres->fd = -1;
> 	while (res && sockres->fd == -1)
> 	{
> 		sockres->fd = socket(res->ai_family,
> 				res->ai_socktype,
> 				res->ai_protocol);
> 		if (!bind(sockres->fd, res->ai_addr, res->ai_addrlen))
> 		{
> 			sockres->family = res->ai_family;
> 		}
> 		else
> 		{
> 			close(sockres->fd);
> 			sockres->fd = -1;
> 		}
> 	}
> 	freeaddrinfo(res);
> 	
> 	if (sockres->fd == -1)
> 	{
> 		socket_dest(sockres);
> 		return NULL;
> 	}
> 
> 	if (hname) socket_set_remote_name(sockres, hname);
> 	else socket_set_remote_name(sockres, "Any Host");
> 
> 	val = 1;
> 	if (setsockopt( sockres->fd,SOL_SOCKET,SO_REUSEADDR, &val, sizeof( int )) <0)
> 		perror("setsockopt()");
> 	val = 1;
> 	if (setsockopt( sockres->fd,SOL_SOCKET,SO_KEEPALIVE, &val, sizeof( int )) <0)
> 		perror("setsockopt()");
> 
> 	if (listen(sockres->fd, backlog ))
> 	{
> 		perror("close()");
> 		socket_dest( sockres );
> 		return NULL;
> 	}
> 	return sockres;
269,282c250,271
< Socket *socket_accept( const Socket *listen_sock ){
<   Socket *new_socket;
<   struct sockaddr saddr;
<   struct sockaddr_in *sin;
<   unsigned int addrlen = sizeof( saddr );
<   int accres;
< 
<   if( (accres = accept( listen_sock->fd, &saddr, &addrlen )) == -1 )
<     return NULL;
< 
<   if( (new_socket = socket_new()) == NULL )
<     return NULL;
< 
<   sin = (struct sockaddr_in *)&saddr;
---
> Socket *socket_accept(const Socket *listen_sock)
> {
> 	Socket			*new_socket;
> 	int			accres;
> 	struct sockaddr_storage	storage;
> 	int			addrlen = sizeof(storage);
> 
> 	if( (accres = accept(listen_sock->fd, (struct sockaddr *)&storage, &addrlen)) == -1)
> 		return NULL;
> 
> 	if ((new_socket = socket_new()) == NULL)
> 		return NULL;
> 
> 	new_socket->fd = accres;
> 	new_socket->port = ((struct sockaddr_in *)&storage)->sin_port;
> 	new_socket->family = ((struct sockaddr_in *)&storage)->sin_family;
> 
> 	if (getnameinfo((struct sockaddr *)&storage, sizeof(storage),
> 		new_socket->remote_name, sizeof(new_socket->remote_name), NULL, 0, 0) != 0)
> 	{
> 		perror("getnameinfo");
> 	}
284,287c273
<   new_socket->fd = accres;
<   new_socket->port = sin->sin_port;
<   socket_set_remote_name( new_socket, inet_ntoa( sin->sin_addr ));
<   return new_socket;
---
> 	return new_socket;
302,309c288,333
< Socket *socket_connect( const char *remote_name, int remote_port ){
<   Socket *res;
<   struct sockaddr_in sin;
< 
<   if( (res = malloc( sizeof( *res ))) == NULL )
<     return NULL;
< 
<   res->port = remote_port;
---
> Socket *socket_connect( const char *remote_name, char *remote_port)
> {
> 	Socket		*sockres;
> 	struct addrinfo	hints;
> 	struct addrinfo	*res;
> 	int		error;
> 
> 	if ((res = malloc(sizeof(*res))) == NULL)
> 		return NULL;
> 
> 	sockres->port = atoi(remote_port);
> 
> 	memset(&hints, 0, sizeof(hints));
> 	/* set-up hints structure */
> 	hints.ai_family = PF_UNSPEC;
> 	hints.ai_flags = AI_PASSIVE;
> 	hints.ai_socktype = SOCK_STREAM;
> 	error = getaddrinfo(remote_name, remote_port, &hints, &res);
> 	if (error)
> 	{
> 		perror(gai_strerror(error));
> 		return NULL;
> 	}
> 	sockres->fd = -1;
> 	while (res && sockres->fd == -1)
> 	{
> 		sockres->fd = socket(res->ai_family,
> 				res->ai_socktype,
> 				res->ai_protocol);
> 		if (!bind(sockres->fd, res->ai_addr, res->ai_addrlen))
> 		{
> 			sockres->family = res->ai_family;
> 		}
> 		else
> 		{
> 			close(sockres->fd);
> 			sockres->fd = -1;
> 		}
> 	}
> 	freeaddrinfo(res);
> 
> 	if (sockres->fd == -1)
> 	{
> 		socket_dest(sockres);
> 		return NULL;
> 	}
311,332c335,336
<   if( (res->fd = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP )) < 0 ){
<     perror( "socket()" );
<     socket_dest( res );
<     return NULL;
<   }
< 
<   sin.sin_family = AF_INET;
<   sin.sin_port   = htons( remote_port );
< 
<   if( socket_resolv_hostname( remote_name, &sin ) == -1 ){
<     socket_dest( res );
<     return NULL;
<   }
< 
<   if( connect( res->fd, (struct sockaddr *)&sin, sizeof( sin )) == -1 ){
<     perror( "connect()" );
<     socket_dest( res );
<     return NULL;
<   }
< 
<   socket_set_remote_name( res, remote_name );
<   return res;
---
> 	socket_set_remote_name(sockres, remote_name);
> 	return sockres;
diff -r camserv-0.5.0/include/camconfig.h camserv-0.5.0-ipv6/include/camconfig.h
12c12
< #define CAMCONFIG_DEF_LISTEN_PORT 9191
---
> #define CAMCONFIG_DEF_LISTEN_PORT "9191"
diff -r camserv-0.5.0/include/socket.h camserv-0.5.0-ipv6/include/socket.h
15c15
< extern Socket *socket_serve_tcp( const char *hname, int port, int backlog );
---
> extern Socket *socket_serve_tcp( const char *hname, char *port, int backlog );
23c23
< extern Socket *socket_connect( const char *remote_name, int remote_port );
---
> extern Socket *socket_connect( const char *remote_name, char *remote_port );
diff -r camserv-0.5.0/relay/relay.c camserv-0.5.0-ipv6/relay/relay.c
87c87
<   int camera_port;          /* Port of the remote camserv or relay */
---
>   char camera_port[50];     /* Port of the remote camserv or relay */
229c229
<     camserv_log( MODNAME, "Couldn't connect to camserv: %s %d", 
---
>     camserv_log( MODNAME, "Couldn't connect to camserv: %s %s", 
613c613
<       camserv_log( MODNAME, "Error connecting to camserv: %s %d",
---
>       camserv_log( MODNAME, "Error connecting to camserv: %s %s",
622d621
<   int localport, remoteport;
638,644c637
<   signal( SIGPIPE, SIG_IGN );
<   if( sscanf( argv[1], "%d", &localport ) != 1 ) {
<     camserv_log( MODNAME, "Error:  port \"%s\" invalid!", argv[ 1 ] );
<     return -1;
<   }
< 
<   if( localport < 1024 )
---
>   if( atoi(argv[1]) < 1024 )
647,652c640,641
<   if( sscanf( argv[3], "%d", &remoteport ) != 1 ) {
<     camserv_log( MODNAME, "Error:  camserv port \"%s\" invalid!", argv[3] );
<     return -1;
<   }
< 
<   strncpy( rdata.camera_ip, argv[2], sizeof( rdata.camera_ip ) - 1);
---
>   strncpy(rdata.camera_port, argv[3], sizeof(rdata.camera_port));
>   strncpy(rdata.camera_ip, argv[2], sizeof( rdata.camera_ip ) - 1);
654d642
<   rdata.camera_port = remoteport;
656c644
<   if( (listen_sock = socket_serve_tcp( NULL, localport, BACKLOG )) == NULL ){
---
>   if( (listen_sock = socket_serve_tcp( NULL, argv[1], BACKLOG )) == NULL ){
