传输层:SOCKET编程之“简单时间服务器实现”

作者Magic_code,转载请附上!

功能:服务器提供时间服务,客户请求时间信息并显示结果

流程如图:


头文件unp.h

1  #ifndef _UNP_H_
2  #define _UNP_H_
3  /* unp.h */
4  #ifdef cplusplus
5  extern "C"{
6  #endif
7  #include <sys/types.h>
8  #include <sys/socket.h>
9  #include <netinet/in.h> /* for struct sockaddr */
10 #include <string.h> /* for strlen() and snprintf() */
11 #include <stdio.h>  /* for printf() */
12 #include <unistd.h> /* for read() */
13 #include <arpa/inet.h>  /* for inet_pton() */
14 #include <stdlib.h> /* for exit() */
15 #define MAXLINE 5
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值