这是 ac 程序(与客户端交互的服务器)我很确定我没有做错太多
我在编译时遇到错误
int main(int argc, char **argv)
{
int sock, fd;
socklen_t client_len;
struct sockaddr_in server, client;
if ((sock = socket(AF_INET, SOCK_STREAM, 0)) == -1)
{
perror("Socket failed");
exit(1);
}
server.sin_family = AF_INET;
server.sin_addr.s_addr = htonl(INADDR_ANY);
server.sin_port = htons (SERVER_PORT);
if (bind ( sock, (struct sockaddr *) &server, sizeof server) == -1);
{
perror("bind failed");
exit(2);
}
listen (sock,1);
while (1)
{
client_len = sizeof (client);
if((fd = accept ( sock, (struct structaddr *) &client, &client_len)) < 0)
{
perror("accepting connection");
exit(3);
}
fprintf(stderr, "\nOpen. \n");
(send (fd, "\nWelcome!\n", 50, 0);
check_stats(fd, fd);
}
close(fd);
fprintf(stderr, "\nClose\n");
exit(0);
}
我已经附上了屏幕截图,虽然我不知道是什么,但这似乎是一个小问题!