[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [libmicrohttpd] libmicrohttpd installation on Solaris 10
From: |
Marek, James |
Subject: |
Re: [libmicrohttpd] libmicrohttpd installation on Solaris 10 |
Date: |
Wed, 18 Apr 2018 16:34:36 +0000 |
Christian,
I found references in the Solaris 10 (SunOs 5.10) Programming Interface Guide
(<https://docs.oracle.com/cd/E19120-01/open.solaris/817-4415/sockets-47146/index.html>)
that suggest that using port 0 in a 'bind' call should bind the socket to any
local port given:
"Internet port numbers less than 1024 (IPPORT_RESERVED) are reserved for
privileged users.
Nonprivileged users can use any Internet port number that is greater than
1024.
The largest Internet port number is 65535.
The port number is not currently bound to some other socket."
I hacked a test program from examples in the Programming Interface Guide and
produced the following program (please forgive any stylistic errors.)
#include <sys/types.h>
#include <netinet/in.h>
#include <sys/socket.h>
struct sockaddr_in6 sin6;
#define MYPORT 0
int sock, length;
int main() {
sock = socket(AF_INET6, SOCK_STREAM, 0);
bzero (&sin6, sizeof (sin6));
sin6.sin6_family = AF_INET6;
(void) inet_pton (AF_INET6, "::ffff:127.0.0.1", sin6.sin6_addr.s6_addr);
sin6.sin6_port = htons(MYPORT);
bind(sock, (struct sockaddr *) &sin6, sizeof sin6);
/* Find out assigned port number and print it out. */
length = sizeof sin6;
if (getsockname(sock,(struct sockaddr *) &sin6, &length)
== -1) {
perror("getting socket name");
exit(1);
}
printf("Socket port #%d\n", ntohs(sin6.sin6_port));
}
I compiled and linked it with:
gcc testport0.c -o testport0 -lsocket -lnsl
When I ran it, I got:
jimarek> ./testport0
Socket port #47378
If you would like me to investigate further, please suggest whatever tests
would be helpful.
Regards,
Jim
-----Original Message-----
From: libmicrohttpd [mailto:address@hidden On Behalf Of Christian Grothoff
Sent: Wednesday, April 18, 2018 3:47 AM
To: address@hidden
Subject: Re: [libmicrohttpd] libmicrohttpd installation on Solaris 10
Dear Marek,
Thanks for your report. As for the "test_options" failure, I wonder what
happens on Solaris 10 if you "bind()" a socket to the port 0.
Given the error message, it seems that the semantics are different from those
on other platforms: on GNU/Linux, bind()ing to 0 means "pick a random free
port". If on Solaris this is simply illegal, that would explain the test
failure.
I don't have a Solaris 10 box. Can you confirm this is the case? If so, we need
to document this limitation on Solaris (bind-to-random-port not
supported) and modify the test to "skip" that check.
Happy hacking!
Christian
On 04/17/2018 09:18 PM, Marek, James wrote:
> FAIL: test_options
>
> ==================
>
>
>
> Failed to bind to port 0: Cannot assign requested address
>
> running test: ip addr option [fail]
>
> FAIL test_options (exit status: 1)
>