tinyhttp 安装和使用 (代码阅读前期准备)

摘要:
系统:ubuntu14.04知识准备:<计算机网络第五版>(美国)Tenenbaum第7.3节万维网I:下载安装包tinyhttpd-0.1.0.tar。gz II:unzip tar zxvftinyhttpd-0.1.0.tar。gz III:安装cdtinyhttpd-0.1.0make,出现错误/usr/include/x86_64 linuxgnu/sys/socket.h:127:12:no

系统:ubuntu14.04

知识准备: <计算机网路第五版>   (美)特南鲍姆   7.3节 万维网

  

一:下载安装包 

tinyhttpd-0.1.0 .tar.gz

二:解压

tar -zxvf tinyhttpd-0.1.0 .tar.gz

三:安装

cd tinyhttpd-0.1.0
make

出现报错

tinyhttp 安装和使用 (代码阅读前期准备)第1张tinyhttp 安装和使用 (代码阅读前期准备)第2张
/usr/include/x86_64-linux-gnu/sys/socket.h:127:12: note: expected ‘socklen_t * __restrict__’ but argument is of type ‘int *extern int getsockname (int __fd, __SOCKADDR_ARG __addr,
            ^
httpd.c: In function ‘main’:
httpd.c:491:24: warning: pointer targets in passing argument 3 of ‘accept’ differ in signedness [-Wpointer-sign]
                        &client_name_len);
                        ^
In file included from httpd.c:16:0:
/usr/include/x86_64-linux-gnu/sys/socket.h:243:12: note: expected ‘socklen_t * __restrict__’ but argument is of type ‘int *extern int accept (int __fd, __SOCKADDR_ARG __addr,
            ^
httpd.c:495:2: warning: passing argument 3 of ‘pthread_create’ from incompatible pointer type [enabled by default]
  if (pthread_create(&newthread , NULL, accept_request, client_sock) != 0)
  ^
In file included from httpd.c:25:0:
/usr/include/pthread.h:244:12: note: expected ‘void * (*)(void *)’ but argument is of type ‘void (*)(int)’
 extern int pthread_create (pthread_t *__restrict __newthread,
            ^
httpd.c:495:2: warning: passing argument 4 of ‘pthread_create’ makes pointer from integer without a cast [enabled by default]
  if (pthread_create(&newthread , NULL, accept_request, client_sock) != 0)
  ^
In file included from httpd.c:25:0:
/usr/include/pthread.h:244:12: note: expected ‘void * __restrict__’ but argument is of type ‘intextern int pthread_create (pthread_t *__restrict __newthread,
            ^
/usr/bin/ld: cannot find -lsocket
collect2: error: ld returned 1 exit status
View Code

  查询原因,是当时的环境为solar,改为linux必须做一些改变,在httpd.c的文件头有说明

/* This program compiles for Sparc Solaris 2.6.
 * To compile for Linux:
 *  1) Comment out the #include <pthread.h> line.
 *  2) Comment out the line that defines the variable newthread.
 *  3) Comment out the two lines that run pthread_create().
 *  4) Uncomment the line that runs accept_request().
 *  5) Remove -lsocket from the Makefile.
 */

解决

运行

zh@zh-pc:~/tinyhttpd-0.1.0$ ./httpd
httpd running on port 43580

访问

在浏览器中输入

http://127.0.0.1:50502/

要加上端口好50502,具体看http程序输出什么

可用结果

tinyhttp 安装和使用 (代码阅读前期准备)第3张

免责声明:文章转载自《tinyhttp 安装和使用 (代码阅读前期准备)》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇乌云主站所有漏洞综合分析&amp;amp;乌云主站漏洞统计Xilinx SDK编译出现undeference to "outbyte"错误的解决办法下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

Qt5 任务栏托盘功能实现

23333 有一阵子没写博客了,研究了挺长时间qt,学到任务栏托盘时简直无语,网上找得到的代码大多是废码,Qt5不支持或者本身就有毛病不能实现却被n多人转来转去的,甚是无语。 简单托盘功能以下在Qt5.5编译通过: #ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow>...

Visual Studio 2013新建工程导入现有代码文件夹并且保持目录结构

本文提供了一个在Windows环境下使用Visual Studio 2013编辑现有源代码并且保持目录结构的方法。本文使用VS2013中文社区版做示例(本版本为免费版,可在VS官网下载),其他版本的VS操作方式类似。打开VS2013,选择【菜单】-【新建】-【从现有代码创建项目】 选择项目类型:Visual C++ 项目文件位置:创建完成后会在这个目录生成...

线程.Qt更新界面

1、信号&槽 机制 即可  ZC:个人暂时 测试下来,类似是 PostMessage(...)的方式:   a、是在各自的线程中执行代码,   b、调用 emit不耗时(指的意思是 像调用PostMessage(...)一样 扔完就算,具体 slot中需要执行多久 不关“emit ???()”的事) 2、测试代码:  2.1、h #ifndef M...

IOCP九:Client退出后投递WSASend

实验过程:         过程一:                 1.Server等待Client到来                2.Client进入                3.Server接受连接,发送"nihaihaoma"                4.Client接收"nihaihaoma",马上退出             ...

BZOJ 1296 粉刷匠(分组背包套DP)

刚开始往网络流的方向想。建不出图。。。 因为每次只能对一行进行染色。每一行都是独立的。 对于每一行,因为格子只能染一次,所以可以发现这是一个多阶段决策问题,这个决策就是当前格子染0还是染1. 令dp[i][j][k](k==0||k==1)表示当前行第i个格子用了j次染色,且这次染色染为k色 的最多有效格子。 这样我们用了O(n*m*m)得出了每一行用了v...

编程珠玑---读书笔记---堆的实现及堆排序

堆是用来表示元素集合的一种数据结构。与“堆内存”不同。堆的性质,第一:顺序性:任何结点的值都小于或者等于其子结点的值,这意味着最小元素位于根结点。 最大顶堆跟这个相反。第二个性质是形状:一种二叉树,最底层的叶子结点尽可能靠左分布,如果有n个结点,那么所有结点到根的距离不会超过logn。 下面用vector来实现堆: 我们规范的从下标1开始,函数定义如下...