httpd
socket
- server = socket(PF_INET, SOCK_STREAM, 0)
- memset
- struct sockaddr_in name;
- name.sin_family = AF_INET;
- name.sin_port = htons(port);
- name.sin_addr.s_addr = htonl(INADDR_ANY);
- setsockopt(httpd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on))) < 0
- bind(server,(struct sockaddr *)&name, & namelen)
- port 如果为0 会sin_port 设置随机端口
- listen(server,backlog)
- while accept client socket
- pthread_create client socket processs
- close(server)