首页 > 其他分享 >实验四 Web服务器2

实验四 Web服务器2

时间:2022-11-30 15:45:33浏览次数:37  
标签:Web int alarm 实验 TIMEOUT copybuf 服务器

基于华为鲲鹏云服务器CentOS中(或Ubuntu),使用Linux Socket实现:
1. Web服务器的客户端服务器,提交程序运行截图
2. 实现GET即可,请求,响应要符合HTTP协议规范
3. 服务器部署到华为云服务器,浏览器用本机的
4. 把服务器部署到试验箱。(加分项)

参考代码:

copy.c:

/* copy.c:
 *
 * Copyright (C) 1998  Kenneth Albanowski <[email protected]>,
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 */

#include <stdio.h>

static char copybuf[16384];

extern int TIMEOUT;

int copy(FILE *read_f, FILE *write_f)
{
  int n;
  int wrote;
  alarm(TIMEOUT);
  while (n = fread(copybuf,1,sizeof(copybuf),read_f)) {
    alarm(TIMEOUT);
    wrote = fwrite(copybuf,n,1,write_f);
    alarm(TIMEOUT);
    if (wrote < 1)
    	return -1;
  }
  alarm(0);
  return 0;
}

在httpd.c文件中增加声明#define HTTPD_DOCUMENT_ROOT "."

进行编译gcc *.c -o webserver -lpthread

查看IP地址:

访问浏览器:输入IP192.168.87.137,可以在本机浏览器中查看

发现虚拟机可以响应

标签:Web,int,alarm,实验,TIMEOUT,copybuf,服务器
From: https://www.cnblogs.com/weihehahaha/p/16938638.html

相关文章

  • 实验四 Web服务器2
    任务详情基于华为鲲鹏云服务器CentOS中(或Ubuntu),使用LinuxSocket实现:Web服务器的客户端服务器,提交程序运行截图实现GET即可,请求,响应要符合HTTP协议规范服务器部署到华......
  • 实验四 wrb服务器2
    实验四Web服务器2基于华为鲲鹏云服务器CentOS中(或Ubuntu),使用LinuxSocket实现:Web服务器的客户端服务器,提交程序运行截图实现GET即可,请求,响应要符合HTTP协议规范服务......
  • 实验四 Web服务器1-socket编程
    任务详情基于华为鲲鹏云服务器CentOS中(或Ubuntu),使用LinuxSocket实现:1.time服务器的客户端服务器,提交程序运行截图2.echo服务器的客户端服务器,提交程序运行截图,服务器......
  • 使用Prometheus+Grafana搭建服务器监控系统
    安装$wgethttps://github.com/prometheus/prometheus/releases/download/v2.7.2/prometheus-2.7.2.linux-amd64.tar.gz$tarxvfzprometheus-2.7.2.linux-amd64.tar.gz$......
  • 实验4-2
    基于华为鲲鹏云服务器CentOS中(或Ubuntu),使用LinuxSocket实现:Web服务器的客户端服务器,提交程序运行截图实现GET即可,请求,响应要符合HTTP协议规范服务器部署到华为云服务......
  • web服务器1-socket编程
    基于华为鲲鹏云服务器CentOS中(或Ubuntu),使用LinuxSocket实现:time服务器的客户端服务器,提交程序运行截图echo服务器的客户端服务器,提交程序运行截图,服务器把客户端传进来......
  • 实验5 继承和多态
    实验任务4pets.hpp#pragmaonce#include<iostream>usingstd::string;classMachinePets{private:stringnickname;public:MachinePets(conststri......
  • Web服务器1-socket编程
    Web服务器1-socket编程1.time服务器的客户端服务器2.echo服务器的客户端服务器,提交程序运行截图,服务器把客户端传进来的内容加入“服务器进程pid你的学号姓名......
  • web服务器2
    基于华为鲲鹏云服务器CentOS中(或Ubuntu),使用LinuxSocket实现:Web服务器的客户端服务器,提交程序运行截图实现GET即可,请求,响应要符合HTTP协议规范服务器部署到华为云服务......
  • 实验四 Web服务器1-socket编程
    基于华为鲲鹏云服务器CentOS中(或Ubuntu),使用LinuxSocket实现:time服务器的客户端服务器,提交程序运行截图echo服务器的客户端服务器,提交程序运行截图,服务器把客户端传进......