资 源 简 介
TCP的客户服务器通信程序 一:程序运行过程 1、运行服务器程序,等待客户端发出请求 2、运行客户端程序,输入客户的IP地址,请求连接 3、若连接成功,服务器端显示客户的IP地址及端口号;客户端接收文件并保存在d:clientls.txt下,否则,显示错误信息。 二:程序实现原理 发送端:打开文件,逐一读取字符到缓冲区(缓冲区大小为1024),若文件大于1024,则成块发送;若小于,则直接发送。 接受端:与发送端同理。-TCP client-server communication program one : running a process, running the server and wait for the client to issue two requests, the client operating procedures, the importation of customer IP address, link request, if successful connection, the server-client shows the IP address and port number ; the client receives the document and preserve d : client ls.txt, otherwise an error message. 2 : Principle procedures transmitter : open the file, read each character to the buffer (buffer size for 1024), and if the document is greater than 1,024, then sent into pieces; If less, then sent directly. Receivers : Send-the same reason.