I'm trying to just bind a socket with this :
#include <stdio.h>
#include <stdlib.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <errno.h>
int main()
{
int fd,namelen,newfd;
struct sockaddr_in sin = {AF_INET};
if(fd=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP)==-1)
printf("socket : %d
",errno);
if(bind(fd,(struct sockaddr *)&sin,sizeof(sin))==-1)
printf("bind : %d
",errno);
}
And that return "bind : 88", I think this mean ENOTSOCK fd, isn't a socket really ? or 88 isn't ENOTSOCK ?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…