I have distilled my porting issue down to the following C program, which used to work on 9.3 (32-bit) and doesn't work on 11.4 (32-bit) (code below).
The result is bind() giving an error
Here's the run of the code on 11.4:
and here's the output on 9.3:
The result is bind() giving an error
Address family not supported by protocol family
, or errno 47.Here's the run of the code on 11.4:
Code:
@tape$ gcc -o s s.c
@tape$ rm -f /tmp/socketfoo; ./s
failed after bind(): 47: Address family not supported by protocol family
@tape$
and here's the output on 9.3:
Code:
@kiko$ cc -o s s.c
@kiko$ rm -f /tmp/socketfoo; ./s
s=3
@kiko$
C:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
main()
{
char *local_filename = "/tmp/socketfoo";
int backlog=5;
int s;
int socksize;
char *saddr;
if ((s = socket(PF_UNIX, SOCK_STREAM, 0)) == -1) {
fprintf(stderr, "failed after socket()\n");
exit(-1);
}
socksize = sizeof (short) + strlen(local_filename) + 1;
saddr = (char *)malloc(socksize);
*(short *)saddr = AF_UNIX;
strcpy(saddr+sizeof(short), local_filename);
if (bind(s, (struct sockaddr *)saddr, socksize) == -1) {
fprintf(stderr, "failed after bind(): %d: %s\n",
errno, strerror(errno));
exit(-1);
}
if (listen(s,backlog) != 0) {
close(s);
fprintf(stderr, "failed after listen()\n");
exit(-1);
}
fprintf(stderr, "s=%x\n", s);
exit(0);
}