摘要: #include <stdio.h>#include <signal.h>#include <arpa/inet.h>#include <sys/types.h>#include <sys/socket.h>#include <unistd.h>#include <netinet/in.h>#include <netinet/ip.h>#include <netinet/ip_icmp.h>#include <netdb.h>#include <setjmp.h> 阅读全文
posted @ 2010-12-05 21:16 糖拌咸鱼 阅读(6277) 评论(1) 推荐(0) 编辑
摘要: Server:#include <stdio.h>#include <string.h>#include <arpa/inet.h>#include <netinet/in.h>#include <sys/socket.h>#define MAXSIZE 1024#define SERV_PORT 2000void dg_echo(int sockfd, struct sockaddr * pcliaddr, socklen_t clilen){ int n; socklen_t len; while(1) { char mesg[M 阅读全文
posted @ 2010-12-05 21:12 糖拌咸鱼 阅读(491) 评论(0) 推荐(0) 编辑
摘要: 最近在学习unix网络编程,现在正在学习tcp的通信。其实,只要建立起了tcp通信,操作远端的计算机就不是什么问题了。正向telnet一样,也是基于tcp/IP协议的。所以这个实验,也算是对telnet功能的一种简单的模拟。 但是,值得注意的问题是关机涉及到系统权限,所以要给运行在Server端的程序以足够的权限,这样才可以在接收到Client端的关机请求时,执行关机。将会模拟如下执行过程:1. 执行 mytelnet 跟上参数telnet服务器 IP地址 127.0.0.12. 输入login 向服务器请求登录,随之服务器会要求输入密码3. 输入一个错误的登录密码 1234. 服务器验证不. 阅读全文
posted @ 2010-12-05 21:07 糖拌咸鱼 阅读(1172) 评论(0) 推荐(0) 编辑
摘要: TCP连接的建立以及利用tcpdump分析连接建立的过程一、实验目的实验1_1:使用Freebsd/Linux操作系统下的C编译器和网络程序的调试方法,掌握TCP连接建立和终止以及调整缓冲区大小的方法。实验1_2:使用ethereal/TCPDump等抓包工具,截取TCP建立过程中产生的数据包,分析连接建立过程。二、实验环境操作系统:Ubuntu 10.04 系统编辑器:vim网络环境:PC1:Ipv4地址10.3.1.210 PC2:Ipv4地址10.3.1.211 两台电脑在同一个网段,可以互相通信,能ping通。代码语言:c语言代码编译器:gcc编译器三、实验内容1.设计思路该实验分为两 阅读全文
posted @ 2010-12-05 20:49 糖拌咸鱼 阅读(1992) 评论(0) 推荐(0) 编辑