readme

来自「"udptar.gz" is an example of UDP socket.」· 代码 · 共 29 行

TXT
29
字号
UDP echo client and server code.The server creates a UDP socket and waits for incoming UDP datagrams(after printing out the port assigned by the operating system).  Eachtime a new datagram is received, the server sends the datagramunchanged back to the sender.The server also prints out the IP address and port number of the client.-----------------The client reads from standard input until end of file (^D) and sendsthe whole thing as a single datagram to the server specified by thecommand line parameters.  The parameters are the hostname and the portnumber. The client calls gethostbyname to determine the IP address ofthe server. For example, to tell the client that the server is runningon the machine foo.cse.cuhk.edu.hk and on port 2030 the client should bestarted like this:client foo.cse.cuhk.edu.hk 2030Once the client sends a datagram it waits until it receives a datagramand then writes the data received to stdout. Since the server is the onlyprocess that knows the port number of the client, we assume it is theonly process that could be sending anything...

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?