Note that there are some explanatory texts on larger screens.

plurals
  1. POGlobal IPv6 adrress is unable to bind on Solaris
    text
    copied!<p>I am trying to bring up a sample code for IPv6 server on Solaris. When i give link local address, it is working fine. But when i give global address, it is failing to bind. Please tell me, that can we use global IPv6 address on Solaris ?</p> <p>This is my code ....</p> <pre><code>#include &lt;unistd.h&gt; #include &lt;errno.h&gt; #include &lt;string.h&gt; #include &lt;sys/types.h&gt; #include &lt;sys/socket.h&gt; #include &lt;netinet/in.h&gt; #include &lt;arpa/inet.h&gt; /* the port users will be connecting to */ #define MYPORT 9000 /* how many pending connections queue will hold */ #define BACKLOG 10 int main(int argc, char *argv[ ]) { /* listen on sock_fd, new connection on new_fd */ int sockfd, new_fd; /* my address information */struct sockaddr_in6 their_addr; socklen_t sin_size; //struct sigaction sa; int yes = 1; if ((sockfd = socket(AF_INET6, SOCK_STREAM, 0)) == -1) { perror("Server-socket() error lol!"); return 0;//exit(1); } else printf("Server-socket() sockfd is OK...\n"); if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &amp;yes, sizeof(int)) == -1) { perror("Server-setsockopt() error lol!"); return 0;//exit(1); }else printf("Server-setsockopt is OK...\n"); /* host byte order */ my_addr.sin6_family = AF_INET6; /* short, network byte order */ my_addr.sin6_port = htons(MYPORT); /* automatically fill with my IP */ inet_pton(AF_INET6,"2345:1111:aaaa::500",&amp;my_addr.sin6_addr); //inet_pton(AF_INET6,"fe80::203:baff:fe50:cbe5",&amp;my_addr.sin6_addr); my_addr.sin6_scope_id=5; /* zero the rest of the struct */ if(bind(sockfd, (struct sockaddr *)&amp;my_addr, sizeof(my_addr)) == -1) perror("Server-bind() error"); return 0;//exit(1); } else printf("Server-bind() is OK...\n"); if(listen(sockfd, BACKLOG) == -1) { perror("Server-listen() error"); return 0;//exit(1); } printf("Server-listen() is OK...Listening...\n"); sin_size = sizeof(struct sockaddr_in6); if((new_fd = accept(sockfd, (struct sockaddr *)&amp;their_addr, &amp;sin_size)) == -1) { perror("Server-accept() error"); //continue; } else printf("Server-accept() is OK...\n"); printf("Server-new socket, new_fd is OK...\n"); printf("Server: Got connection from \n"); /* this is the child process */ /* child doesn’t need the listener */ char buf[1024]; int numbytes=0; if((numbytes = recv(new_fd, buf, 1024, 0)) == -1) { perror("recv()"); return 1;//exit(1); } else printf("Client-The recv() is OK...\n"); buf[numbytes] = '\0';printf("Client-Received: %s", buf); if(send(new_fd, "This is a test string from server!\n", 37, 0) == -1) perror("Server-send() error lol!"); /* parent doesn’t need this*/ close(new_fd); printf("Server-new socket, new_fd closed successfully...\n"); return 0; } </code></pre> <p>Thank you ....</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload