进阶day11-网络编程_TCP服务端实现

This commit is contained in:
2026-03-26 15:57:20 +08:00
parent 5172c55034
commit aab9f96208
2 changed files with 64 additions and 0 deletions

View File

@@ -35,6 +35,9 @@ public class TcpClientDemo04 {
OutputStream os = client.getOutputStream();
os.write("淘宝的官网".getBytes());
//注意:当发送完毕请求数据后,要设置结束的标记,否则服务器会长时间等待客户端的请求数据
client.shutdownOutput();
//3.获取字节输入流,接收响应数据
InputStream is = client.getInputStream();
//一次读字节数组的方式来读取响应数据