嵌入式培训机构四个月实训课程笔记(完整版)-Linux网络编程第二天-tcp编程练习(物联技术666)

这篇笔记详细记录了使用C语言实现一个简单的TCP服务器的过程,包括创建套接字、绑定、监听和处理客户端连接。代码中展示了如何读取客户端请求并根据请求发送响应,涉及网络编程和Linux系统调用。
摘要由CSDN通过智能技术生成

点赞+关注,功德无量。更多配套资料,欢迎私信。
网盘链接:百度网盘 请输入提取码
 

WebServer编程:

--------------------------------------

#include <stdio.h>

#include <stdlib.h>

#include <string.h>                                    

#include <unistd.h>

#include <sys/socket.h>

#include <netinet/in.h>

#include <arpa/inet.h>                               

#include <pthread.h>

#include <sys/types.h>

#include <sys/stat.h>

#include <fcntl.h>

void *Client_Process(void *arg)

{

       char recvbuf[2048] = "";                              // 接收缓冲区

       char httpbuf[200]="";

       char http_path[200]="";

       int fd,send_num=0;

       char buf_send[1024]="";

      

       char head[]="HTTP/1.1 200 OK\r\n"\

                          "Content-Type: text/html\r\n"\

                          "\r\n";   

       char err[]=   "HTTP/1.1 404 Not Found\r\n"          \

                          "Content

  • 16
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值