单个连接的连续服务(长连接) 在一个循环里不断得读取请求, 处理, 然后发送响应. serv = tcp_socket(); listen(serv); sock = accept(serv); while(1){ packet_read(sock, request); if(request == EXIT){ break; } response = handle_packet(request); packet_write(sock, response); } close(sock)
1