求助网络c 语言程序设计

来源:百度知道 编辑:UC知道 时间:2024/06/24 13:02:17
目标:本实验目的是使用IP网络提供的TCP传输协议,实现一个简单的TCP客户/服务器程序。
步骤:本实验为TCP客户/服务器实验。实验内容:TCP echo客户/服务器设计与实现。TCP echo客户/服务器程序完成以下功能:客户从标准输入读一行文本,写到服务器上;服务器从网络输入读取此行,并回射(echo)给客户;客户读此回射行,并将其写到标准输出。

这是一个TCP 的网络实验
另一个是UDP 的网络实验,内容跟这个基本一样,只是把TCP 改成UDP

求懂的人指导 ~ 这个要如何做(用c 语言程序设计实现)
补充一下,我已经得到了完整的程序代码,并且在baidu 贴吧,网络吧发了帖子,标题为“C 语言网络程序,求指教 ~ ”所有的代码都贴到上面了 ~

现在就只是想请懂的人指导一下 ~ 这些程序的各部分是什么意思?比如加一下注释 ~ 就可以给你分 ~

The typical TCP client goes through four basic steps:
1. Create a TCP socket using socket().
2. Establish a connection to the server using connect ().
3. Communicate using send() and recv().
4. Close the connection with close().

int connect(int socket, struct sockaddr *foreignAddress, unsigned int addressLength)
int send(int socket, const void *msg, unsigned int msgLength, int flags)
int recv(int socket, void *rcvBuffer, unsigned int bufferLength, int flags)

The typical TCP server goes through four basic steps:
1. Create a TCP socket using socket().
2. Assign a port number to the socket with bind().
3. Tell the system to allow connections to be made to that port, using l i s t e n ( ) .
4. Repeatedly do the following:
Call accept () to get a new socket for each client connection.
Communicate with the client via that new socket using send() and recv().
Close the client connection using clo