Created
January 4, 2021 21:20
-
-
Save kengonakajima/bc04a8d88ce16e7898e0ca057127868b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <sys/socket.h> | |
#include <stdio.h> | |
#include <netinet/in.h> | |
#include <errno.h> | |
#include <string.h> | |
int main() { | |
int fd=socket(AF_INET,SOCK_STREAM,0); | |
struct sockaddr_in sa; | |
sa.sin_family=AF_INET; | |
sa.sin_port=htons(80); | |
sa.sin_addr.s_addr=INADDR_ANY; | |
int re=bind(fd,(struct sockaddr*)&sa,sizeof(sa)); | |
printf("bind ret:%d (%s)\n",re, strerror(errno)); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment