基于Linux的socket多客户多文件传输系统.docx
文本预览下载声明
摘要线程(thread)技术早在60年代就被提出,但真正应用线程到操作系统中去。使用多线程的理由之一是和进程相比,它是一种非常节俭的多任务操作方式。在Linux系统下,启动一个新的进程必须分配独立的地址空间,建立众多的数据表来维护它的代码段、堆栈段和数据段。而运行于一个进程中的多个线程,它们之间使用相同的地址空间,共享大部分数据,启动一个线程所花费的空间远远小于进程所花费的空间,而且,线程间彼此切换所需的时间也远远小于进程间所需要的时间。?使用多线程的理由之二是线程间方便的通信机制。对不同进程来说,它们具有独立的数据空间,要进行数据的传递只能通过通信的方式进行,这种方式费时且很不方便。由于同一进程下的线程之间共享数据空间,所以一个线程的数据可以直接为其它线程所用,这样快且方便。?在计算机中,凡是提供服务的一方我们称为服务端(Server),而接受服务的另一方我们称作客户端(Client)。不过客户端及伺服端的关系不见得一定建立在两台分开的机器上,提供服务的伺服端及接受服务的客户端也有可能都在同一台机器上,这样在同一台机器上就同时扮演伺服端及客户端。?线程间方便的通信机制可以使得在我们在服务端和客户端方便的进行通信传输与各种操作,可以通过运用多线程机制方便实现上传、下载文件;增加、删除用户;以及在服务端进行文件的管理。?本文介绍了基于TCP/IP协议的客户端和服务器通信的基础上,在Linux的环境对套接口进行编程,实现了双客户间的通信.关键字:双客户通信;Linux;TCP/IP协议;Socket套接口;I/O复用AbstractThread (thread) technology as early as in the 1960s have been proposed, but the real application threads to go to the operating system. One of the reasons is the use of multiple threads and processes compared to, it is a very frugal multitasking operating mode. In the Linux system, start a new process must be assigned a separate address space, the establishment of a large number of data tables to maintain its code segment, stack and data segments. While running on a process of multiple threads between them using the same address space, shared most of the data, the space it takes to start a thread process takes far less than the space, and, switching between threads each required time is far less than the time required for inter-process.Reason two is the use of multiple threads to facilitate inter-thread communication mechanisms. Different processes, they have separate data space, the data to be transmitted only by way of communicating, consuming and inconvenient in this way. Because the shared data space between threads of the same process under a thread so that data can be used directly by other threads, so quick and easy.In the computer, all serving one we call the server (Server), and served other we call the client (Client). But the relationship between the client and the servo end not necessarily bu
显示全部