首页 基于TCPIP的网络聊天工具的设计与实现—免费毕业设计论文

基于TCPIP的网络聊天工具的设计与实现—免费毕业设计论文

举报
开通vip

基于TCPIP的网络聊天工具的设计与实现—免费毕业设计论文基于TCPIP的网络聊天工具的设计与实现—免费毕业设计论文 基于TCP/IP的网络聊天工具的设计与实现 摘要 Socket 接口是TCP/ IP 网络的API(应用程序接口) ,Windows Sockets (Winsock) 是一个 基于Socket 模型的API。本文通过论述了Windows 环境下的实现计算机数据传输服务的机 制,提供了一种网络环境下实现计算机通信的手段,分析了TCP/ IP 协议的体系结构、组成与 功能以及通过TCP/ IP 协议实现异构型网络互连的机理。对TCP/ IP 协议提供的...

基于TCPIP的网络聊天工具的设计与实现—免费毕业设计论文
基于TCPIP的网络聊天工具的 设计 领导形象设计圆作业设计ao工艺污水处理厂设计附属工程施工组织设计清扫机器人结构设计 与实现—免费毕业设计论文 基于TCP/IP的网络聊天工具的设计与实现 摘要 Socket 接口是TCP/ IP 网络的API(应用程序接口) ,Windows Sockets (Winsock) 是一个 基于Socket 模型的API。本文通过论述了Windows 环境下的实现计算机数据传输服务的机 制,提供了一种网络环境下实现计算机通信的手段,分析了TCP/ IP 协议的体系结构、组成与 功能以及通过TCP/ IP 协议实现异构型网络互连的机理。对TCP/ IP 协议提供的两种通信功 能进行了分析,辩证地提出了它们不同的应用场合。本聊天工具使用VC++语言和较成熟的微 软的mfc71作为开发语言,本文详细介绍了本聊天工具的开发过程。并从系统的需求分析、 系统分析、详细设计的整个开发过程进行全面论述。最后,给出了在TCP/ IP 基础上开发通信 应用程序的编程模型和实现要点,对用户开发应用程序有一定参考意义。 关键词: 网络;TCP/ IP 协议 通信编程 VC++ Abstract Socke interface is a API of TCP/ IP network and Winsock is another API which is base of the model of Socket ,This article discuss a service mechanismof computer data communications, providing a means of achieve computer communications in networks environment , analyzes the system construction , composition and function of TCP/ IP protocol , and realization mechanism intercommunication between isomerous networks through TCP/ IP protocols. The paper also analyzes two kinds of communication functions provided by TCP/ IP protocols , and proposes their different application occasions dialectically .this article use takes fundamentally with the VC++ language,in detail introduced this management system management system performance history.And from system demand analysis, system analysis, detailed design entire performance history .. Finally , the paper gives programming models and realization keys of developing communication programs , which will provide some reference value for users who develop application programs. Key words :network TCP/ IP protocols communication program VC++ 目录 摘要 .................................................................................................................................................. 1 Abstract ............................................................................................................................................. 1 1 引言 .............................................................................................................................................. 3 2系统分析 ....................................................................................................................................... 4 2.1 需求分析 ........................................................................................................................... 4 2.2 用到主要技术分析 ........................................................................................................... 4 2.2.1 Socket 编程的相关知识与技术 ............................................................................. 4 2.2.2 TCP/IP协议介绍 ..................................................................................................... 5 2.2.3 TCP/IP协议下的WinSock编程 ............................................................................ 6 2.2.4 局域网文件传输 ..................................................................................................... 6 2.2.5 程序语言的选择 ..................................................................................................... 7 2.3 算法分析 ........................................................................................................................... 7 3.系统总体 方案 气瓶 现场处置方案 .pdf气瓶 现场处置方案 .doc见习基地管理方案.doc关于群访事件的化解方案建筑工地扬尘治理专项方案下载 设计....................................................................................................................... 8 3.1 开发及运行环境 ............................................................................................................. 8 3.2系统功能的总体逻辑层次 ................................................................................................ 8 3.3系统设计目标 .................................................................................................................... 8 3.4系统功能............................................................................................................................ 9 4.系统的详细设计........................................................................................................................... 9 4.1 系统设计的原理 ............................................................................................................... 9 4.2 系统功能设计 ................................................................................................................. 10 4.2.1 客户端功能程序设计 ......................................................................................... 10 4.2.2 服务端程序设计 ................................................................................................. 11 5系统功能实现.............................................................................................................................. 14 5.1服务端的实现 .................................................................................................................. 14 5.2客户端功能模块的实现 .................................................................................................. 16 6 结束语 ........................................................................................................................................ 19 7 致谢 ............................................................................................................................................ 20 参考文献 ........................................................................................................................................ 20 1 引言 Internet上的聊天室一向是一个吸引人的地方,多用C语言或是web网络语言进行设计。Internet上数据传输协议主要有TCP和UDP。TCP是有连接协议(它要求计算机进行对话时必须先建立连接。保证数据传送安全到达目的地。UDP是无连接协议。它只是将信息送到网络上,并不检查数据是否到达了目的地。要进行实时会话。则应该采用TCP协议。本程序采用的协议就是TCP协议。传输控制协议TCP (Transmission Control Protocol) 是Internet 最基本的网络通信协议, 它由一系列协议组成,其中核心协议是传输层的TCP和UDP( User Datagram Protocol, 用户数据报协议)协议。TCP 协议属于“ 面向连接,可靠传输”的类型, 面向连接的传输意味着在进行通信以前, 需要在两个系统之间建立逻辑连接, 在每个数据传输的过程中都需要进行应答以保证数据包的完整, 这种 方法 快递客服问题件处理详细方法山木方法pdf计算方法pdf华与华方法下载八字理论方法下载 可以保证数据传输的可靠性,但所需的网络开销较大;UDP 协议属于“ 面向无连接, 不可靠传输”的类型, 该协议只负责接收和传送上层协议传递的消息, 它本身不做任何的检测、修改与应答, 网络开销一般要小于TCP协议。在优良的网络环境, UDP 的工作效率较TCP 协议要高。在Windows 环境下开发网络应用程序, 通常都是使用Microsoft的网络编程接口, 即Windows 套接字Windows Socket( 简称Winsock), 它包含在Winsock.dll 中的一组API 中,用于在网络上传输数据和交换信息, 编程人员需要熟悉和掌握相关的网络协议、系统的底层知识以及网络软硬件技术, 因而Winsock 编程相当复杂。所幸的是, MFC的CSocket类对WinSock 进行了有效的封装, 并不需要直接与Winsock 的API 打交道, 调用CSocket类的一些方法成员,就可以方便进行机器之间的通讯,使得对Winsock 的访问大大简化。 1.1 网络聊天工具的特性 (1)多功能。作为一种即时通信工具,一般聊天工具支持显示朋友在线、寻呼、聊天、即时传送文字、语音和文件等功能,支持视频功能的视频QQ。 (2)超时空。通过互联网,信息传递摆脱了时空的限制,只要交流双方是与网络相连通的,不管对方身在何处,双方都可以进行即时对话。这种散点式的人际传播对于整个组织机构的健康运作有着不可低估的作用。 (3)互动性。网络聊天接近于现实生活的最大量交流,是一种面对面的共时态的直接交流。它可以进行实时的一对一、一对多、多对多的互动交流,实时地对对方做出反应。可以通过留言,即使对方不在线,也可以在上线的同时第一时间收到信息。网络聊天工具还可以与移动通讯终端、IP 电话网、无线寻呼等多种通讯方式相连,是一种方便、实用、高效的即时通信工具。 (4)平等性。网络世界的虚拟性、平等性以及网络信息传递的瞬时性,满足了大学生轻松交往的要求。正是这些特性,可以使大学生暂时掩盖自身任何的缺点和不足,可以摆脱现实交往中容易产生的各种矛盾,更不必顾及舆论的压力而使得师生在交流过程中受到更少的束缚,最终使大学生在虚拟的网络中能够更轻松地面对友(爱)情,交往需求在网络中得到充分的满足。 (5)距离感。网络的距离掩盖了真实的缺点,容易产生美感。心理学家分析,距离可以使人产生朦胧,朦胧为想象提供了足够的空间,想象则可以产生美感。 1.2 预期完成的功能 本次毕业设计从实际工程应用角度出发,以计算机网络原理为指导,结合当前网络中的一些常用技术,编程实现基于TCP/IP的网络聊天工具,该聊天工具具有聊天室聊天、广播聊天、二人私聊以及文件传输功能的聊天工具网上聊天1.0版。 2系统分析 2.1 需求分析 通过调查研究,要求系统满足有以下功能; 1) 由于操作人员的计算机知识普遍较差,要求有良好的人机界面。 2) 客户端操作简单,用户登录,进入聊天室。 3) 实现广播聊天、聊天室聊天、二人私聊、文件传输四个功能。 4) 服务端操作,显示所有在线用户,选择某用户后可以进行删除操作 5) 系统退出。 6) 系统要体现界面友好,使用方便的特性。 2.2 用到主要技术分析 2.2.1 Socket 编程的相关知识与技术 Socket 进行网络通信有两种主要的方式。第一种为流方式(Stream Socket), 也称面向连接方式, 用于实现TCP 协议。在这种方式下, 两个应用程序之间先要建立一种虚拟的连接。只有两端的程序成功地进行了握手之后才能开始传输数据。其特点是通信可靠, 对数据有校验和重发的机制, 通常用作数据文件的传输, 如FTP、TELNET等。第二种为数据报文方式(Datagram Socket),又称无连接方式, 在进行数据传送以前两端的程序不需要任何沟通。数据报文方式由于取消了重发校验机制,能够达到较高的通信速率, 可以用作对数据可靠性要求不高的通信, 如实时的语音、图像转送、广播消息等。面向连接的Socket工作中有比较严格的操作次序。在这种类型的Socket 工作过程中,必须首先启动服务器端,通过调用socket()函数建立一个socket 对象, 然后调用bind()函数将该socket对象和本地网络地址绑定到一起,再调用listen()函数使该socket对象处于侦听状态,并规定它的最大请求的数量;之后要—直等到客户机有连接请求的时候服务器才会再次被激活;收到客户机请求以后, 服务器调用accept()函数来决定是否接受该连接; 客户在建立Socket 对象后就可调用connect()函数和服务器建立连接; 连接一旦建立, 客户机和服务器之间就可以通过调用基本的网络I/O 函数来发送和接收数据; 一旦数据传送结束, 双方都必须关闭初始创建的socket 对象。在网络通信中, 由于网络拥挤或一次发送的数据量过大等原因, 经常会发生交换的数据在短时间内不能传送完、收发数据的函数不能返回的现象, 这种现象叫阻塞。Winsock 对有可能发生阻塞的函数提供了两种处理方式——阻塞和非阻塞方式。在阻塞方式下, 收发数据的函数在被调用后一直要到传送完毕或者出错才能返回。阻塞方式是UNIX 中Socket 工作的默认方式, 可是在Windows 系统中这种方式是无法容忍的。在Windows 系统中, 如果一个函数长时间没有返回值, 系统就很难为其他的程序分配出运行时间, 常见的现象就是对输入没有响应, 刷屏缓慢, 系统反应迟钝等。因此, 在编程时, 应尽量使用非阻塞方式。 Berkeley Socket 支持四种作用域: UNIX Domain (AF-UNIX) , Internet (AF- INET) , XeroxNS (AF-NS) 和IMP 链路层(AF- IMPLINK) ,提供了四种Socket 类型: 流式 ( SOCK-STREAM) , 数据报 (SOCK-DGRAM) , 原始( SOCK-RAM) 和顺序分组 (SOCK-SEQPACKET) , 而WinSock 仅支持AF- IN2ET ,即TCP/ IP 协议,提供流式、数据报和原始三种套接字。流式套接字基于TCP 协议,提供面向连接的服务;数据报套接字基于UDP 协议,提供无连接的服务; 原始套接字允许对低层协议IP 或ICMP 的直接访问。 TCP/ IP 协议用主机地址标识网络上的主机,用端口号标识主机上的程序,通信模式如图1 所示。而Socket 是一整数,它与主机地址和端口号以及协议相联系。 程序1 程序2 程序1 程序2 面向连接 端口号1 端口号3 端口号1 端口号3 无连接 端口号2 端口号4 端口号2 端口号4 主机地址1 主机地址2 图1 TCP/ IP 协议的通信模式 2.2.2 TCP/IP协议介绍 TCP/IP协议并不完全符合OSI的七层参考模型。传统的开放式系统互连参考模型,是一种通信协议的7层抽象的参考模型,其中每一层执行某一特定任务。该模型的目的是使各种硬件在相同的层次上相互通信。这7层是:物理层、数据链路层、网路层、传输层、话路层、表示层和应用层。而TCP/IP通讯协议采用了4层的层级结构,每一层都呼叫它的下一层所提供的网络来完成自己的需求。这4层分别为: 应用层:应用程序间沟通的层,如简单电子邮件传输(SMTP)、文件传输协议(FTP)、网络远程访问协议(Telnet)等。 传输层:在此层中,它提供了节点间的数据传送服务,如传输控制协议(TCP)、用户数据报协议(UDP)等,TCP和UDP给数据包加入传输数据并把它传输到下一层中,这一层负责传送数据,并且确定数据已被送达并接收。 互连网络层:负责提供基本的数据封包传送功能,让每一块数据包都能够到达目的主机(但不检查是否被正确接收),如网际协议(IP)。 网络接口层:对实际的网络媒体的管理,定义如何使用实际网络(如Ethernet、Serial Line等)来传送数据。 使用IP 协议的TCP 是专门设计用于不可靠的因特网上提供可靠的、端到端的字节流通信的协议。通过在发送方和接收方分别创建一个套接字的通信端点可以获得TCP 服务。每个套接字有一个套接字序号(地址) ,它包含主机的IP 地址以及一个主机本地的16 位号码,称为端口。为了获得TCP 服务,必须在发送方的套接字与接收方的套接字之间明确地建立一个连接。 一个套接字有可能被多个连接同时使用。换言之,两个或更多个连接可能同时连接到同一个套接字上。连接由两端的套接字标识符来识别,即(socket1 ,socket2) 序号小于256 的端口称为通用端口,例如想要使用Telnet 建立一个远程登录会话,可以使用23 号端口。所有的TCP 连接均是全双工和点到点的。全双工意味着可以同时进行双向传输。点到点是每个连接只有 两个端点。TCP不支持多点播送或广播。 TCP 连接是字节流而不是报文流。报文边界并不按头尾衔接方式保存。例如,如果发送进程将4 块512 字节的数据写到TCP 流上,那么这些数据可能按4 个512 字节的数据块, 或者2 个1024字节的数据块,以及一个2 048 字节的数据块和其它一些方式传送到接收进程。接收方无法检测出这些数据是以哪种单位写入的。当一个应用程序把数据送给TCP 实体时, TCP 根据自己的判断,可能会立刻将其发送出去或缓存起来(为了收集较大量的数据,然后发送) 。然而,有时候应用程序很想将数据立即发送出去,为了强制立即发送数据,应用程序可以使用PUSH标志,通知TCP 不能耽搁数据的发送。简而言之,TCP 被设计成能动态满足互联网的要求,并且足以面对多种出错。 基于TCP/IP协议的接收套接字通信机制示意图如下图2 应用程序 套接字 套接子仿真器 传输驱动程序接口 传输协议 (TCP/IP) 图2 套接字通信机制示意图 2.2.3 TCP/IP协议下的WinSock编程 在TCP/ IP 协议下,Socket 是一种极为重要的网络编程接口。Socket (套接字) 接口最初是美国加州大学Berkely 分校为UNIX开发的一种网络编程接口 。由于Windows 的异军突起,迫切需要将套接字接口移植到Windows 中。于是,在90 年代初, Sun Micro system ,Microsoft , JSB Corporation , FTP Software 和Micro dyne 公司联合起来共同制定了Windows Sockets ( 简称WinSock ) 规范 编程规范下载gsp规范下载钢格栅规范下载警徽规范下载建设厅规范下载 , 使Windows下的Socket 应用开发规范化和 标准 excel标准偏差excel标准偏差函数exl标准差函数国标检验抽样标准表免费下载红头文件格式标准下载 化。WinSock 不仅提供了标准Berkely Socket 功能调用集,而且进行了重要扩充,以更好地适合Windows的消息驱动机制。这些扩充的功能调用都以WSA(Windows Sockets Asynchronous) 为前缀,提供网络事件的异步选择机制。 2.2.4 局域网文件传输 用于计算之间文件传输的方法有多种:1) 使用FTP 文件传输,这种方法需在文件服务器上建立FTP 服务器,用户建立连接并进行FTP 文件复制,使用起来较复杂,需用户名和密码建立连接; 2) 源方建立共享目录,目标方通过计算名称和共享访问进行文件拷贝,这种方法需源方共享影响安全性,且需要给用户必要的用户名和密码,使用时需建立网络连接。文件传输方法还有很多,但应用在并行分步计算,并计算结果自动进行计算机间传输文件方面均不太好用。 我们的程序所采用的是基于TCP/IP 协议的Winsock 编程原理,对这方面的程序设计有所了解的人都应该知道对于这种编程模型一般都是采用客户机/服务器(Client/Server)方式,在这个程序里面也正是采用这种基本的方法。为了方便使用,我们把客户机和服务器合而为一,但其实质还是一样的。 通信时主要可以分为两个部分:一个部分是用于传送控制信息,例如发送文件的请求,文件的名称、大小等,由于这方面的数据量比较小,为了方便起见,我们采用了MFC 所提供的CSocket 类的串行化技术来实现;传输通道采用Windows 平台上的WinSock[1 ] 是在TCP/ IP 协议基础上的一种网络编程接口。它借鉴了Unix 平台Berkeley (BSD) 套接字方案的编程思想。局域网中各计算应用程序之间使用WinSock 传送数据非常方便,因此这里采用WinSock 数据传输方法,进行不同计算机应用之间数据传输。为保证网络通信不受网络故障和网络中计算机系统退出和重新启动的影响,将WinSock 网络通信设计成无连接的UDP 模式。但UDP 模式为非可靠传输方式,为保证数据在UDP 模式下的可靠传输,采用加返校重传功能。 2.2.5 程序语言的选择 本系统采用VC++.NET 2003作为程序开发语言。VC++是Windows平台上的C++编程环境,学习VC要了解很多Windows平台的特性并且还要掌握MFC、ATL、COM等的知识,难度比较大。Windows下编程需要了解Windows的消息机制以及回调(callback)函数的原理;MFC是Win32API的包装类,需要理解文档视图类的结构,窗口类的结构,消息流向等等;COM是代码共享的二进制标准,需要掌握其基本原理等等。 VC作为一个主流的开发平台一直深受编程爱好者的喜爱,但是很多人却对它的入门感到难于上青天,究其原因主要是大家对他错误的认识造成的,严格的来说VC++不是门语言,虽然它和C++之间有密切的关系,如果形象点比喻的话,可以C++看作为一种“工业标准”,而VC++则是某种操作系统平台下的“厂商标准”,而“厂商标准”是在遵循“工业标准”的前提下扩展而来的。VC++应用程序的开发主要有两种模式,一种是WIN API方式,另一种则是MFC方式,传统的WIN API开发方式比较繁琐,而MFC则是对WIN API再次封装,所以MFC相对于WIN API开发更具备效率优势,但为了对WINDOWS开发有一个较为全面细致的认识,笔者在这里还是以讲解WIN API的相关内容为主线。 2.3 算法分析 进行通信的两台计算机,一台作为服务器,另一台作为客户机。在服务器端,首先可调用Winsock 控件的Listen 方法进入监听状态,监听代表本进程的LocalPort ,等待客户端的连接请求(Connection Request) 。 在客户端,可将服务器的IP 地址(或计算机名) 设置为RemoteHost ,将服务器端的Localport 设置为RemotePort ,然用调用Winsock 控件的Connect 方法,请求与服务器建立连接;服务器收到连接请求后,通过调用Accept方法在2 台计算机之间建立通信连接;连接建立后,通信双方便可以通过SendData 方法向对方发送数据;数据到达对方后,将触发DataArrival 事件,收到数据的一方可以在DataArrival 事件的处理代码中通过GetData方法得到从对方发送过来的数据。 3.系统总体方案设计 3.1 开发及运行环境 硬件平台: 1) CPU:P4 1.8GHz。 2) 内存:256MB以上。 软件平台: 1) 操作系统:Windows XP/ Windows 2000。 2) 开发语言:VC++ 3) 开发平台:Visual Studio 2003 4) 分辨率:最佳效果1024×768像素 3.2系统功能的总体逻辑层次 本次毕业采用了面向连接的数据流,即基于TCP协议的连接方式,其工作流程如图1 所示。 图2面向连接的Socket 工作流程图 3.3系统设计目标 系统稳定性:在设计该系统时,很重要的一个问题就是系统的长期稳定运行,因为客户端可能很多个,考虑到系统的运行环境等条件,必须从系统分析的高度给与足够重视,保证服务器能够较长时间的运行 系统健壮性:系统需要长期稳定地运行,而用户在日常的工作中要进行各种各样的操作,难免会产生各种各样的误操作和错误,这就打破了本系统的正常运行流程,可能导致预想不到的后果。因此,在本系统的设计过程中,我们将预先考虑各种各样的误操作及后果,采取相应的预防措施,确保不产生灾难性的后果,保证系统的健壮性。 良好的适应性:系统必须具有良好的扩展能力和修改方便的特点,以适应不同的变化。只有建立了稳定的模型和良好的数据接口,才能保证系统具有良好的适应性。 界面友好:用户界面是聊天工具与主要环节,所以,应充分考虑用户的习惯和喜好,以方便用户使用为原则。 3.4系统功能 本次毕业设计聊天工具主要实现以下功能: 1) 客户端功能:用户登录,进入聊天室。广播聊天、聊天室聊天、二人私聊、文件传 输四个功能。 2) 服务端功能:显示所有在线用户,选择某用户后可以进行删除操作 客户端功能模块图 客户端 广播聊天 私人聊天 聊天室聊天 文件传输 图3 客户端功能模块 4.系统的详细设计 4.1 系统设计的原理 本程序基TCP/IP协议。采用服务器与客户端模式。选用VC++程序设计语言。服务器端连接过程简化为:?设置连接所用的端口?开始监听此端口?接到请求后建立连接?可以发送和接收数据?不用了就关闭Socket连接。 客户端简化为:?设置服务器地址r要连接的地址?设置连接是所用到的端口?发送连接请求?建立连接成功?可以发送和接收数据?不用了就关闭Socket连接。 MFC Windows Socket 类包括CAsyncSocket 和CSocket 类。Visual C++对众多的socket 函数进行了封装, MFC 提供的封装类是: CAsyncSocket 和CSocket 类, 它们使编程工作变得相对简单尤其是CSocket 类:首先CAsyncSocket 类所提供的唯一的抽象就是将与套接字相联系的Windows 消息以回调函数的形式表示, 因此它带来的唯一方便就是程序员无需自行处理Winsock 的I/O 模型, 而对于如阻塞处理、字节顺序差异以及Unicode 等依然负有责任并有灵活的控制权。其次,CSocket 类是CAsyncSocket 类的派生类, 它提供了对通过Carchive 对象使用套接字工作的更高级抽象。CSocket 类的使用比CAsynCSocket 类更加容易, 它继承了CAsyncSocket 类的许多封装了API 的成员函数, 并且管理了通信的大多数方面, 这使得用户从原来不得不使用原始API 或者CAsyncSocket 类的烦杂的工作中解脱出来。更加重要的是CSocket 和Carchive 类提供了对于同步操作Carchive 对象十分重要的阻塞功能, 且CSocket 通过与CSocketFile 和Carchive 一起使用来管理对象数据的发送和接收, 使发送数据和操作变得简单明了 4.2 系统功能设计 4.2.1 客户端功能程序设计 首先介绍客户端的用户登录窗体,输入用户名和服务器ip地址后进入聊天室。 输入用户名 服务器ip 登陆 取消 图4 客户端登陆窗口 然后出现图4,客户端聊天主窗体。 消息显示框 (下拉框)选择聊天对象 (复选框)二人私聊 发送消息 传输文件 图 5功能及模块实现窗口 图 4中聊天对象下拉框中,包括所有人选项和登陆某某用户名的下拉框选项,如下图5, 所有人 张三 李四 … 图6选择用户下拉框 点击文件传输按钮后,在文件传输对话框中会显示相应的传输文件,只要双击你所需要 的文件,选择相应的存储路径后即可存储文件。 本实验采用上述方式实现广播聊天、聊天室聊天、二人私聊、文件传输四个功能 4.2.2 服务端程序设计 启动服务端后进入 在线用户: 删除 张三 **时间 进入聊天室 李四 **时间 进入聊天室 退出 显示所有在线用户,选择某用户后可以进行踢线操作。 本实验采用VS 2003 为平台利用VC++开发语言进行程序编写。 下面介绍Client端基本类: CChatSocket继承与CSocket类,主要用于TCP/IP通讯连接 CSendview类用户显示消息: 对于文件传输,首先定义了下列数据结构来存储文件的相关信息, typedef struct //与服务器通信语言结构 { int iCommand; long lFileOffset; long lFileLength; char sClientPath[128]; char sServerPath[128]; }MSGREQUEST; typedef struct //请求线程参数 { char sIP[15]; int iPort; MSGREQUEST msgRequest; LPVOID ptr; }PARAMREQUEST; typedef struct //文件列表结构 { long lFileLength; char sServerPath[128]; }MSGFILELIST; typedef struct //反映文件状态的结构 { long lFileOffset; char sServerPath[128]; }MSGFILESTATUS; 然后在客户端与服务器端分别定义了用于文件传输的类CTCPClient_FT; 下面给出客户端请求接受文件部分代码: void CTCPClient_FT::RequestFile(MSGREQUEST msgRequest) { PARAMREQUEST* pParam = new PARAMREQUEST;//请求参数 strcpy(pParam->sIP, m_sIP); pParam->iPort = m_iServerPort; pParam->msgRequest.iCommand = msgRequest.iCommand ; pParam->msgRequest.lFileLength = msgRequest.lFileLength; pParam->msgRequest.lFileOffset = msgRequest.lFileOffset; strcpy(pParam->msgRequest.sClientPath, msgRequest.sClientPath); strcpy(pParam->msgRequest.sServerPath, msgRequest.sServerPath); pParam->ptr = m_pWnd; DWORD id; HANDLE h = CreateThread(NULL, 0, ThreadRequestFile, pParam, 0, &id);//创建新的线程 CloseHandle(h); } 5系统功能实现 5.1服务端的实现 服务器端有个CSocket 的派生类CListeningSocket对象指针来监听端口等待用户登陆, 而用另一个CSocket 的派生类对象CClientSocket 的指针组来处理和每一个客户端的交互过程。派生类CListeningSocket的回调函数OnAccpet()与客户端建立套接字层次的连接。派生类CClientSocket 的回调函数OnReceive()与接收每一个已连接的数据传输。 启动服务端,显示服务端界面: 图6 用户管理界面 下面给出服务器端接收消息的部分代码: CMsg* CServerDoc::ReadMsg(CClientSocket* pSocket) {static CMsg msg; //CMsg包含消息的格式和方法 CClientSocket* pSock;//创建客户端sock TRY//捕捉异常 { pSocket->ReceiveMsg(&msg);//接收消息 if(msg.type=="-1")//判断消息类型 { bool found=false; for(POSITION posname=m_connectionList.GetHeadPosition();posname;) { pSock = (CClientSocket*)m_connectionList.GetNext(posname); if(pSock->name==msg.from ) {found=true; pSocket->needdel=true; delsocket(); return NULL; } } if(found==false) { pSocket->name=msg.from; Message1(msg.from); Message1("进入聊天室\r\n"); } } if(msg.type=="-2") { Message1(msg.from); Message1("离开聊天室\r\n");} int i=atoi(msg.type); if(i>=0 && i<=32) { talk(i,msg.from,msg.to,msg.m_strText); } m_msgList.AddTail(msg.m_strText); typelist.AddTail(msg.type); fromlist.AddTail(msg.from); tolist.AddTail(msg.to); seclist.AddTail(msg.sec); clrlist.AddTail(msg.clr); } 打开客户端,显示客户端登陆界面: 从名称的下拉列表框中选择登录的用户,单击确定,进入该用户聊天的界面,同时服务端也 会显示出该用户的进入信息: 5.2客户端功能模块的实现 在聊天对象中,选择所有人,在聊天信息中,输入信息,单击发送信息。 此功能用到的代码如下: void CSendView::OnSend() { CChatDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); CString strText; GetDlgItem(IDC_TEXT)->GetWindowText(strText); UpdateData(TRUE); if(strText=="") return; CString ll; int j=m_typecom.GetCurSel(); if(j>=0) ll.Format("%d",j); pDoc->msg.type=ll; pDoc->msg.from=pDoc->m_strHandle; pDoc->msg.to=to; if(sec) pDoc->msg.sec="TRUE"; else pDoc->msg.sec="FALSE"; pDoc->msg.m_strText=strText; BYTE i1=GetRValue(pDoc->clr); BYTE i2=GetGValue(pDoc->clr); BYTE i3=GetBValue(pDoc->clr); (pDoc->msg.clr).Format("%d,%d,%d",i1,i2,i3); pDoc->SendMsg(); strText=_T(""); GetDlgItem(IDC_TEXT)->SetWindowText(strText); } 当有很多用户进入聊天室后,在聊天对象中,选择想要聊天的人名,勾选二人世界,在聊天信息中,输入信息,单击发送信息。这时信息只显示在聊天人的客户端中,而在其他客户端,并不显示该信息。 文件传输: 在文件传输系统中,利用Winsock 实现了大文件在Client 和Server 间的无差错快速传输。在通信程序编写中使用了MFC 中的CSocket 类,通过修改发送缓冲区和接收缓冲区的大小,解决了利用Winsock 发送和接收大数据量文件的难题,满足了系统快速传输要求。 局域网内文件分发的编程思路局域网内文件分发的编程思路是, 服务器软件和客户端软件使用同一个端口, 待连接以后, 客户端给服务器发送请求, 包括待传文件的文件名、文件大小等, 如果服务器接受, 就开始传文件。Socket 通信在Windows 中以排队形式由操作系统进行处理, 基本方式是请求和应答, 而且接收方和发送方必须相互协同工作,否则就会造成数据丢失。因此,不能用类似于for 的循环语句来实现对多组数据的发送,更不能用循环语句来接收数据; 另外, 对于较大的文件, 应该分批传输,一般每次1至4KB为宜,以保证数据传输的稳定性, 同时也不至于过多地占用系统资源。 只要在添加需要传送的文件,其可以显示文件的大小和路径: 接受文件: 单击接受文件,打开文件传输窗体,双击需要接受的文件,选择保存路径,开始传输: 此功能用到的主要代码如下: void CClient_FileTransferDlg::OnDblclkListFilelist(NMHDR* pNMHDR, LRESULT* pResult) { // TODO: Add your control notification handler code here NMLISTVIEW* pListView = (NMLISTVIEW*)pNMHDR; int iSel = pListView->iItem; if(iSel == -1) return; CString strFileName = m_ListFile.GetItemText(iSel, 0); CFileDialog dlg(FALSE, NULL, strFileName.GetBuffer(0), OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, "All Files(*.*)|*.*||", this); if(dlg.DoModal() != IDOK) return; CString strClientPath = dlg.GetPathName(); CFile file; BOOL bOpen = file.Open(strClientPath, CFile::modeCreate|CFile::modeWrite, NULL); if(!bOpen) { MessageBox("文件创建或打开失败~请确认路径再重试~"); return; } file.Close(); MSGREQUEST msgRequest; msgRequest.iCommand = FILEDATA; msgRequest.lFileLength = m_ListFile.GetItemData(iSel); msgRequest.lFileOffset = 0; strcpy(msgRequest.sClientPath, strClientPath.GetBuffer(0)); strcpy(msgRequest.sServerPath, m_ListFile.GetItemText(iSel, 5)); DWORD dwStartTick = GetTickCount(); char sStartTick[20]; sprintf(sStartTick, "%u", dwStartTick); m_ListFile.SetItemText(iSel, 6, sStartTick); m_pClient->RequestFile(msgRequest); *pResult = 0;} 6 结束语 如今, 人们不仅可以在网上查询自己需要的资源, 而且可以通过网络进行实时的沟通, 从实时性和有效性上都超过了用信件和E-Mail, 并且在费用上要低于电话。因而各种聊天服务备受用户青睐, 在这方面的开发与应用也较多[1], 聊天服务也成为互联网提供的重要服务之一。互联网的大多数网站都建有聊天室, 并且有专业聊天网站提供聊天服务。进入20 世纪90 年代后, 随着计算机和网络技术的发展,很多数据处理系统都采用开放系统结构的客户机/服务器(Client/Server)网络模型,即客户机向服务器提交请求,服务器对请求做相应的处理兵执行被请求的任务,然后将结构返回给客户机。这种方式隐含了在建立客户机/服务器间通信是的非对称性。客户机/服务器模型工作时要求有一套为客户机和服务器所共识的惯例来保证服务能够被提供( 或被接受) , 这一套惯例包含了一套协议, 它必须在通信的两头都被实现。根据不同的实际情况, 协议可能是对称的或非对称的。在对称的协议中每一方都有可能扮演主从角色; 在非对称协议中一方被不可改变地认为是主机, 而另一方则是从机。一个对称协议地例子是Internet中用于终端仿真地Telnet, 而非对称协议地例子是Internet 中的http。无论具体的协议是对称的或是非对称的, 当服务被提供时必然存在客户进程和服务进程。一个服务程序通常在一个众所周知地地址监听客户对服务地请求, 也就是说, 服务进程一直处于休眠状态, 直到一个客户对这个服务地址提出连接请求。在这个时刻, 服务程序被“惊醒”并且为客户提供服务——客户地请求作出适当的反应。 利用Socket 开发网络应用程序, 可以屏蔽网络低层复杂的结构和协议, 因此开发的应用软件可以在各种网上运行, 而不必关心是何种网络以及服务器或客户机在网上的具体位置和数据传输的细节, 实现异构网互连十分容易. 而且利用Socket 来编写网络应用, 程序结构清晰明了, 便与升级和维护。 Winsock 使得Windows 环境下底层通信协议的协议细节对网络应用程序开发人员而言是透明的,为广大程序员提供了一个统一的、简化的编程界面。通过Winsock 不但可以很方便地实现不同计算机之间的相互通信,而且可以实现同一计算机中不同进程之间的通信,还可 计算机之间的远程控制。 Winsock 的最新版本不但支持TCP/ IP 协议簇,而且还实现联网的 支持其它的通信协议. 随着Windows 操作系统和Internet 的普及,Winsock 作为网络编程的新标准,必将为计算机网络开拓出更广阔的应用前景。 本文以Visual C++的MFC(微软基本类库)作为基本的开发基础, 使用Socket 套接字作为开发的应用程序开发模型, 完成了网络在线聊天系统的设计及实现过程, 通过测试表明该系统可以方便的建立连接, 断开连接, 实现网络在线聊天系统的在线好友查找, 发送消息和接收消息等功能。 通过本次毕业设计,我也感受到了开源的方便,遇到什么问题,上网一查,就知道该怎么弄了,以前做个课程设计都是怕别人和我的一样,不愿意给别人看,现在知道了程序弄不出来是多么的着急,学习都是相互的,互相研究才能共同进步的.以后要多多注意这方面的事情,本次毕业设计是我工作前一次很好的演练和实践的机会,是培养独立思考问题和自学能力的锻炼,使我意识到必须努力学习才能才工作中体现自己的价值,适应社会的需要。 7 致谢 我的作品基于TCP/IP的网络聊天工具的设计与实现,达到了我预先的效果。在此我要在此衷心感谢老师的悉心指导,在他们的接触中,从他们一丝不苟的工作态度和平易近人的交谈中,我感受到了老师们扎实的知识、对工作的责任感和积极乐观的生活态度。我的论文的完成,离不开这位老师的指导与关爱。感谢在大学四年的学习生活中所有关心和帮助过我的各位老师和同学。 参考文献 [1] Douglas E Comer , David L Stevens. Internet Working With TCP/ IP Vol ?:Design , Implementation and Internal [M] . 张娟,等译. 北京:电子工业出版社,1998. [2] 李鹏. 计算机通信技术及其程序设计[M] . 西安:西安电子科技大学出版社,1998. [3] 黄超. Windows网络编程[M] . 北京:人民邮电出版社,2000 [4] 刘运强,王汇源1Socket 和多线程在视频传输的应用[J ] 山东大学学报(工学 版) ,2004 ,34(2) :452501 [5] 胡涛Visual C + + NET 编程技术体验[M] 北京:清华大学出版社,1991 [6] 苏炳秒,黄劲 基于Socket 技术的煤矿远程监控系统[J ]工矿自动化,2003 , (1) :372391 [7] 袁立民 一种视频图像传输的多线程实现方法[J] 电子技术应用,1999 ,25(1) :492501 [8] 蒋东兴 Windows Sockets 网络程序设计大全[M]北京:清华大学出版社,1999 [9] 王骞,等 一类网络控制系统的建模及分析[J ] 控制工程,2004 ,11(6) :5292532 ooling?" Cirocco frowned from one picture to the other. "Just a lot of little black dots to me." "Well, yeah. You can't see anything without the comparometer. That's it right there." She indicated an area with her little %er. "Let's go take a look." Cirocco rummaged through her locker and found a pea-green shipsuit that smelled as good as any of them. Most of the handy velcro patches were peeling. Her room was at the bottom of the carousel, midway between ladders three and four. She followed Gaby around the curving floor, then pursued her up the ladder. Each rung was a little easier than the last until, at the hub, they were weightless. They pushed off from the slowly rotating ring and drifted down the central corridor to the science module. SCIMOD in NASA-ese. It was kept dark to make the instruments easier to read, and was as colourful as the inside of a juke- box. Cirocco liked it. Green lights blinked and banks of television screens hissed white noise through confetti clouds of snow. Ugene Springfield and the Polo sisters floated around the central holo tank. Their faces were bathed in the red glow. Gaby handed the plates to the computer, punched up an image-intensifying program, and indicated the screen Cirocco should watch. The pictures were sharpened, combined, then rapidly alternated. Two miniscule dots blinked, not far from each other. "There it is," Gaby said proudly. "Small proper motion, but the plates are only twenty-three hours apart." Gene called to them. "Orbital elements are coming in," he said. Gaby and Cirocco joined him. Cirocco glanced down and saw his arm go possessively around Gaby's waist, looked quickly away, noting that the Polo sisters had seen it and were just as careful not to notice. They had all learned to stay out of each other's affairs. Saturn sat in the middle of the tank, fat and brassy. Eight blue circles were drawn around it, each larger than the last, each in the equatorial plane of the rings. There was a sphere on each circle, like a single pearl on a string, and beside the pearls were names and numbers: Mnemosyne, Janus, Mimas, Enceladus, Tethys, Dione, Rhea, Titan, and Hyperion. Far beyond those orbits was a tenth one, visibly tilted. That was Iapetus. Phoebe, the most distant, could not be shown on the scale they were using. Now another circle was drawn in. It was an eccentric ellipse, almost tangent to the orbits of Rhea and Hyperion, cutting right across the circle that represented Titan. Cirocco studied it, then straightened. Looking up, she saw deep lines etched on Gaby's forehead as her fingers flew over the keyboard. With each pro- gram she called up, the numbers on her screen changed. "It had a very close call with Rhea about three million years ago," she noted. "It's safely above Titan's orbit, though perturbations must be a factor. It's far from stabilized." "Meaning what?" Cirocco asked. "Captured asteroid?" Gaby suggested, one eyebrow raised doubtfully. "The proximity to the equatorial plane would make that un- likely," one of the Polo sisters said. April or August? Cirocco wondered. After eighteen months together she still couldn't tell them apart. "I was afraid you'd see that." Gaby chewed a knuckle. "Yet if it was formed with the others, it ought to be less eccentric." The Polo shrugged. '"There are ways to explain it. A catastrophic event in the recent past. It Bill's tongue had started at Cirocco's toes and was now exploring her left car. She liked that. It had been a memorable journey. Cirocco had loved every centimeter of it; some of the stops along the way had been outrageous. Now he was worrying her earlobe with his lips and teeth, tugging gently to turn her around. She let it happen. He nudged her shoulder with his chin and nose to get her turning faster. She began to rotate. She feltw what he was doing. She locked her legs around his hips and let him do the moving. Bill was forty, the oldest of the crew, and had a face dominated by a lumpy nose and jowls that could have graced a bassett hound. He was balding and his teeth were not pretty. But his body was lean and hard, ten years younger than his face. His hands were neat and clean, precise in their movements. He was good with machinery, but not the greasy, noisy kind. His tool kit would fit in his shirt pocket, tools so tiny that Cirocco wouldn't dare handle them. His delicate touch paid off when he made love. It was matched by his gentle disposition. Cirocco wondered why it had taken her so long to find him. There were three men aboard Ringmaster, and Cirocco had made love to them all. So had Gaby Pla was taller than most of them. She thought it was more in his eyes, which were soft and brown and liquid. And his smile. Those eyes and that smile had done nothing for Gaby, just as Cirocco's charms had not interested Gene, her second choice. "Mat are you smiling about?" Bill asked. "Don't you think you're giving me enough reason?" she countered, a little breathlessly. But the truth was she had been thinking of how amusing the four of them must have looked to Bill, who had stayed out of the shuffle of bodies. That seemed to be his style, to sit back and let people sort themselves out, then move in when it began to be depressing. Calvin had certainly been depressed. So had Cirocco. Whether from preoccupation with Gaby or just inexperience, Calvin had not been much of a lover. Cirocco thought it was a little of both. He was quiet, shy, and bookish. His records showed he had spent most of his life in school, carrying an academic load that left little room for fun. Gaby just didn't care. The Science Module of Ringmaster was the finest toy a girl ever had. She loved her work so much she had joined the astronaut corps and graduated at the top of her class so she could watch the stars without an annoying atmosphere, even though she hated to travel. When she was working she noticed nothing else, did not think it odd that Calvin spent almost as much time in SCIMOD as she did, waiting for the chance to hand her a photographic plate or a lens cloth or the keys to his heart. Gene didn't seem to care, either. Cirocco sent out signals that could have drawn her five to We if the FCC had known about them, but Gene wasn't receiving. He just grinned with that boyish, tousle-haired Aryan ideal face and talked about flying. He was to be the pilot of the Satellite Excursion Module when the ship reached Saturn. Cirocco liked flying, too, but there came a time when a woman wanted to do something else. But eventually Calvin and Cirocco got what they had wanted. Soon after, neither wanted it anymore. Cirocco didn't know what the problem was with Calvin and Gaby; neither of them talked about it, but it was obvious that it worked only passably at best. Calvin continued to see her, but she saw Gene, too. Gene had apparently been waiting for Cirocco to stop chasing him. As soon as she did, he began to sidle up and breathe heavily in her ear. She didn't like that much, and the rest of his technique was no better. When he was through making cove, it al- most seemed he expected to he thanked. Cirocco had never been easily impressed; Gene would have been astonished to learn where he fell on her scale of one to ten. Bill had happened almost by accident-though she had since learned that few accidents happened around Bill. One thing led to another, and now they were about provide a pornographic demonstration of Newton's Third Law of Motion, the one that used to refer to , action and reaction." Cirocco had done some calculations on the matter, and had found that the force of ejaculation was not nearly enough to account for the orgasmic acceleration she always observed at that moment. The cause was certainly spasms of the large muscles of the leg, but the effect was beautiful and a little frightening, as though they had become big, fleshy balloons losing air, forced away from each other at the moment of closest approach. They would careen and carom, and finally come to rest together again. Bill felt it building, too. He grinned, and the hydroponic lamps made his crooked teeth luminescent. PUBIREL DISPATCH #0056 5112125 DSV RINGMASTER (NASA 447D, LS/1, HOUSTON-COPER- NICUS GCR BASELINE) IONES, CIROCCO, MISCOM FOR PARAPHRASING AND IMMEDIATE RELEASE BEGINS: Gaby has settled on Themis as the name for the new moon. Calvin agrees with her, though they arrived at the name from different directions. Gaby mentions the alleged sighting of (what would have been) a tenth moon of Saturn by William Henry Picketing---discoverer of Phoebe, Saturn's outermost moon-in 1905. He named it Themis, and no one ever saw it again. Calvin points out that five of the Saturnian moons are already named after the Titans of Creek myth (which is a special interest of his; see PUBIREL DISPATCH #0009,113124) and a sixth is called Titan. Themis was a Titan, so Calvin's mind is appeased. Themis has things in common with the moon Pickering thought he saw, but Gaby is not convinced he actually sighted it. (If he did, she would not be listed as its discoverer. But to be fair, it seems too small and dim to be seen in even the best Lunar scopes.) Gaby is formulating a cataclysmic theory of Themis 'formation, the result of a collision between Rhea and a wandering asteroid. Themis might be the remnant of that asteroid, or a chunk knocked off of Rhea itself. So Themis is proving an interesting challenge for "--that wonderful gang of idiots you all know so well by now, the crew of the DSV Ringmaster." Cirocco leaned back from the typer touchplate, stretched her arms over her head, and cracked her knuckles. "Tripe," she muttered. "Also bullshit." The green letters glowed on the screen in front of her, still with no period at the bottom. It was a part of her job she always delayed as long as possible, but the NASA flacks could no longer be ignored. Themis was an uninteresting chunk of rock, by all indications, but the publicity department was desperate for something to hang a story on. They also wanted human interest, "personality journalism," as they called it. Cirocco tried her best, but could not bring herself to go into the kind of detail the release writers wanted. Which hardly mattered anyway, since what she had just written would be edited, re-written, discussed in conference, and generally jazzed up to "humanize" the astronauts. Cirocco sympathized with their goal. Few people gave a damn about the space program. They felt the money could he better spent on Earth, on Luna, and at the LS colonies. Why pour money down the rat-hole of exploration when there was so much benefit to be derived from things that were established on a businesslike basis, like Earth-orbital manufacturing? Exploration was terribly expensive, and there was nothing at Saturn but a lot of rock and vacuum. She was trying to think of some fresh, new way to justify her presence on the first exploratory mission in eleven years when a face appeared on her screen. It might have been April, and it might have been August. "Captain, I'm sorry to disturb you." "That's okay. I wasn't busy." "We have something up here you should see." "Be right up." She thought it was August. Cirocco had worked on keeping them straight since twins generally resent being mistaken for each other. She had gradually realized that April and August didn't care. But April and August were not ordinary twins. Their full names were April 15/02 Polo and August 3/02 Polo. That was what was written on their respective test tubes, and that is what the scientists who had been their midwives had put on the birth certificates. W'hich had always struck Cirocco as two excellent reasons why scientists should not be allowed to fool around with experiments that lived and breathed and cried. Their mother, Susan Polo, had been dead for five years at the time of their births, and. could not protect them. Nobody else seemed ready to give them any mothering, so they had only each other and their three clone-sisters for love. August had told Cirocco once that the five of them had only one close friend while growing up, and that had been a Rhesus monkey with a souped-up brain. He had been dissected when the girls were seven. "I don't want to make it sound too brutal," August had said on that occasion, a night when some glasses of Bill's soybean wine had been consumed. "Those scientists were not monsters. A lot of them behaved like kindly aunts and uncles. We had just about anything we wanted. I'm sure a lot of them loved us." She had taken another drink. "After all," she said, "we cost a lot of money." What the scientists got for their money was five quiet, rather spooky geniuses, which is just what they ordered. Cirocco doubted they had bargained for the incestuous homosexuality, but felt they should have expected it, just as surely as the high I.Q. They were all clones of their mother-the daughter of a third-generation Japanese-American and a Filipino. Susan Polo won the Nobel prize in physics and died young. Cirocco looked at August as the woman studied a photo on the chart table. She was exactly like her famous mother as a young woman: small, with jet-black hair and a trim figure, and dark, expressionless eyes. Cirocco had never thought Oriental faces were as similar as many Caucasians found them to be, but April and August's faces gave nothing away. Their skin was the color of coffee with lots of cream, but in the red light of the Science Module August looked almost black. She glanced at, Cirocco, showing more excitement than usual for her. Cirocco held her eye for a moment, then looked down. Against a field of pinpoint stars, six tiny lights were arranged in a perfect hexagon.. Cirocco looked at it for a long time. "It's the damdest thing 1 ever saw on a starplate," she conceded. "What is it?,, Gaby was strapped to a chair on the other side of the compartment, sucking coffee from a plastic bulb. "It's the latest exposure of Themis," she said. "I took it over the last hour with my most sensitive equipment and a computer program to justify the rotation." "I guess that answers my question," Cirocco said. "But what isit?" Gaby waited a long time before replying, taking another sip. "It is possible," she said, sounding detached and dreamy, "for several bodies to orbit around a common center of gravity. Theoretically. No one's ever seen it. The configuration is called a rosette." Cirocco waited patiently. When no one said anything, she snorted. "in the middle of Saturn's satellite system? For about five minutes, maybe. The other moons would perturb them." "There's that," Gaby agreed. "And how would it happen in the first place? The chances against it are tremendous." "There's that, too." April and Calvin had entered the room. Now Calvin looked up. "Isn't anyone going to say it? This isn't a natural arrangement. Somebody made this." Gaby rubbed her forehead. "You haven't heard it all. 1 bounced radar signals off it. They came back telling me Themis was over 1300 kilometers in diameter. Density figures all cockeyed, too, making it less dense than water by quite a bit. 1 thought 1 was getting screwed-up readings because 1 was working at the limits of my equipment. Then 1 got the picture." "Six bodies or one?" Cirocco asked. "I can't tell for sure. But everything points to one." "Describe it. What you think you know." Gaby consulted her printout sheets, but obviously did not need them. The figures were clear in her mind. "Themis is 1300 klicks across. That makes it Saturn's third largest moon, about the size of Rhea. It must be flat black all over, except those six points. This is by far the lowest albedo of any body in the solar system, if that interests you. It's also the least dense. There's a strong possibility it's hollow, and a good chance it's not spherical. Possibly disc-shaped, or toroidal, like a donut. Either way, it seems to turn like a plate rolling along itsthink I didn't like you. I do. Like you, I mean." "Don't they have soyburgers?" Twidge asked. As soon as the waitress left, the docent began passing out the pink folders she'd brought with her. "These will explain the working philosophy of the Cyclists," she said, handing me one, "along with practical information on the menstrual cycle." She handed Twidge one. "It looks just like those books we used to get in junior high," Mother said, looking at hers. "'A Special Gift,' they were called, and they had all these pictures of girls with pink ribbons in their hair, playing tennis and smiling. Blatant misrepresentation." She was right. There was even the same drawing of the fallopian tubes I remembered from my middle school movie, a drawing that had always reminded me of Alien in the early stages. "Oh, yuck," Twidge said. "This is disgusting." "Do your math," Karen said. Bysshe looked sick. "Did women really do this stuff?" The wine arrived, and I poured everyone a large glass. The docent pursed her lips disapprovingly and shook her head. "The Cyclists do not use the artificial stimulants or hormones that the male patriarchy has forced on women to render them docile and subservient." "How long do you menstruate?" Twidge asked. "Forever," Mother said. "Four to six days," the docent said. "It's there in the booklet." "No, I mean, your whole life or what?" "A woman has her menarche at twelve years old on the average and ceases menstruating at age fifty-five." "I had my first period at eleven," the waitress said, setting a bouquet down in front of me. "At school." "I had my last one on the day the FDA approved ammenerol," Mother said. "Three hundred and sixty-five divided by twenty-eight," Twidge said, writing on her slate. "Times forty-three years." She looked up. "That's five hundred and fifty-nine periods." "That can't be right," Mother said, taking the slate away from her. "It's at least five thousand." "And they all start on the day you leave on a trip," Viola said. "Or get married," the waitress said. Mother began writing on the slate. I took advantage of the ceasefire to pour everyone some more dandelion wine. Mother looked up from the slate. "Do you realize with a period of five days, you'd be menstruating for nearly three thousand days? That's over eight solid years." "And in between there's PMS," the waitress said, delivering flowers. "What's PMS?" Twidge asked. "Pre-menstrual syndrome was the name the male medical establishment fabricated for the natural variation in hormonal levels that signal the onset of menstruation," the docent said. "This mild and entirely normal fluctuation was exaggerated by men into a debility." She looked at Karen for confirmation. "I used to cut my hair," Karen said. The docent looked uneasy. "Once I chopped off one whole side," Karen went on. "Bob had to hide the scissors every month. And the car keys. I'd start to cry every time I hit a red light." "Did you swell up?" Mother asked, pouring Karen another glass of dandelion wine. "I looked just like Orson Welles." "Who's Orson Welles?" Twidge asked. "Your comments reflect the self-loathing thrust on you by the patriarchy," the docent said. "Men have brainwashed women into thinking menstruation is evil and unclean. Women even called their menses 'the curse' because they accepted men's judgment." "I called it the curse because I thought a witch must have laid a curse on me," Viola said. "Like in 'Sleeping Beauty.'" Everyone looked at her. "Well, I did," she said. "It was the only reason I could think of for such an awful thing happening to me." She handed the folder back to the docent. "It still is." "I think you were awfully brave," Bysshe said to Viola, "going off the ammenerol to have Twidge." "It was awful," Viola said. "You can't imagine." Mother sighed. "When I got my period, I asked my mother if Annette had it, too." "Who's Annette?" Twidge said. "A Mouseketeer," Mother said and added, at Twidge's uncomprehending look. "On TV." "High-rez," Viola said. "The Mickey Mouse Club," Mother said. "There was a high-rezzer called the Mickey Mouse Club?" Twidge said incredulously. "They were days of dark oppression in many ways," I said. Mother glared at me. "Annette was every young girl's ideal," she said to Twidge. "Her hair was curly, she had actual breasts, her pleated skirt was always pressed, and I could not imagine that she could have anything so messy and undignified. Mr. Disney would never have allowed it. And if Annette didn't have one, I wasn't going to have one either. So I asked my mother--" "What did she say?" Twidge cut in. "She said every woman had periods," Mother said. "So I asked her, " 'Even the Queen of England?' And she said, 'Even the Queen.'" "Really?" Twidge said. "But she's so old!" "She isn't having it now," the docent said irritatedly. "I told you, menopause occurs at age fifty-five." "And then you have hot flashes," Karen said, "and osteoporosis and so much hair on your upper lip you look like Mark Twain." "Who's--" Twidge said. "You are simply reiterating negative male propaganda," the docent interrupted, looking very red in the face. "You know what I've always wondered?" Karen said, leaning conspiratorially close to Mother. "If Maggie Thatcher's menopause was responsible for the Falklands War." "Who's Maggie Thatcher?" Twidge said. The docent, who was now as red in the face as her scarf, stood up. "It is clear there is no point in trying to talk to you. You've all been completely brainwashed by the male patriarchy." She began grabbing up her folders. "You're blind, all of you! You don't even see that you're victims of a male conspiracy to deprive you of your biological identity, of your very womanhood. The Liberation wasn't a liberation at all. It was only another kind of slavery!" "Even if that were true," I said, "even if it had been a conspiracy to bring us under male domination, it would have been worth it." "She's right, you know," Karen said to Mother. "Traci's absolutely right. There are some things worth giving up anything for, even your freedom, and getting rid of your period is definitely one of them." "Victims!" the docent shouted. "You've been stripped of your femininity, and you don't even care!" She stomped out, destroying several squash and a row of gladiolas in the process. "You know what I hated most before the Liberation?" Karen said, pouring the last of the dandelion wine into her glass. "Sanitary belts." "And those cardboard tampon applicators," Mother said. "I'm never going to join the Cyclists," Twidge said. "Good," I said. "Can I have dessert?" I called the waitress over, and Twidge ordered sugared violets. "Anyone else want dessert?" I asked. "Or more primrose wine?" "I think it's wonderful the way you're trying to help your sister," Bysshe said, leaning close to Viola. "And those Modess ads," Mother said. "You remember, with those glamorous women in satin brocade evening dresses and long white gloves, and below the picture was written, 'Modess, because...' I thought Modess was a perfume." Karen giggled. "I thought it was a brand of champagne!" "I don't think we'd better have any more wine," I said. ### The phone started singing the minute I got to my chambers the next morning, the universal ring. "Karen went back to Iraq, didn't she?" I asked Bysshe. "Yeah," he said. "Viola said there was some snag over whether to put Disneyland on the West Bank or not." "When did Viola call?" Bysshe looked sheepish. "I had breakfast with her and Twidge this morning." "Oh." I picked up the phone. "It's probably Mother with a plan to kidnap Perdita. Hello?" "This is Evangeline, Perdita's docent," the voice on the phone said. "I hope you're happy. You've bullied Perdita into surrendering to the enslaving male patriarchy." "I have?" I said. "You've obviously employed mind control, and I want you to know we intend to file charges." She hung up. The phone rang again immediately, another universal. "What is the good of signatures when no one of ever uses them?" I said and picked up the phone. "Hi, Mom," Perdita said. "I thought you'd want to know I've changed my mind about joining the Cycd all the hormone fluctuations! Anybody'd have to be crazy to want to go through that when they didn't have to! How did you stand it before the Liberation?" "They were days of dark oppression," I said. "I guess! Well, anyway, I quit and now my docent is really mad. But I told her it was a case of personal sovereignty, and she has to respect my decision. I'm still going to become a floratarian, though, and I don't want you to try to talk me out of it." "I wouldn't dream of it," I said. "You know, this whole thing is really your fault, Mom! If you'd told me about the pain part in the first place, none of this would have happened. Viola's right! You never tell us anything!" The End
本文档为【基于TCPIP的网络聊天工具的设计与实现—免费毕业设计论文】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
is_037433
暂无简介~
格式:doc
大小:282KB
软件:Word
页数:0
分类:工学
上传时间:2018-10-15
浏览量:12