扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
//服务端程序 2!{$4NX718ur }/
import java.io.*; @?vXu.{
import java.net.*; V(-X> c)
public class MyServer $*%z+
{ _L\%rGK
public static void main(String[] args) throws IOException HGU\nnnD\E
{ &P paM &
ServerSocket server=new ServerSocket(5678); &JP/I{9C0
Socket client=server.accept(); G7iJ,i;e
BufferedReader in=new BufferedReader(new InputStreamReader(client.getInputStream())); =1KT461#W
PrintWriter out=new PrintWriter(client.getOutputStream()); )[$}P$; 5k
while(true) Qy <n1[
{ ?13`RgJ>/
String str=in.readLine(); oW(bKe
System.out.println(str); `^;rp`rl
out.println("has receive...."); 4!') uy
out.flush(); cwQ6GSzx1
if(str.equals("end")) ={0av:|K\V
break; j{zbLD^3
} Ss C{RCqo
client.close(); v;pZ1e$
} wL7SUw=c
} LGnHw6_
'/>L,~`B{O
//客户端程序 x 5frm=[0
import java.net.*; kPz9Pm!a
import java.io.*; sHN^E^qs)
5(n}f f%
public class Client |IgS&
{ /[*/I@eH
static Socket server; hX;m=<YD
public static void main(String[] args)throws Exception Gb3YJ+F
{ daQLl-JI
server=new Socket(InetAddress.getLocalHost(),5678); ':Y<Q[UlA
BufferedReader in=new BufferedReader(new InputStreamReader(server.getInputStream())); BtRmX8-
PrintWriter out=new PrintWriter(server.getOutputStream()); C{QN~Ug q
BufferedReader wt=new BufferedReader(new InputStreamReader(System.in)); >M.p3SnX
while(true) q$53).wA
{ Wg\U9O^rE
String str=wt.readLine(); Pd#'9T6I
out.println(str); Gi8u5Vp [
out.flush(); Z8Op 8B
if(str.equals("end")) I&&,6ii/
{ E:HGC!xX
break; E&m R@
} 2],YT/ r
System.out.println(in.readLine()); ,`WbS]Y4L
} e`y Hu
server.close(); ??PXg
} *yaK<nG7Cn
} ^Q6e$6c
import java.io.*; cHJ]ih{MB4*+-FzsrDB
import java.net.*; xg;$U&r
bzMt&X:w
public class MyServer ObUnf`
{ m0X"+ #'bs
public static void main(String[] args) throws IOException V!1h yK
{ f7*yK ]G
ServerSocket server=new ServerSocket(5678); fs<h#8m
while(true) hl c5]T
{ 0f.q 8Y^2%
Socket client=server.accept(); V 0wbTgI
BufferedReader in=new BufferedReader(new InputStreamReader(client.getInputStream())); TzU*[v!3
PrintWriter out=new PrintWriter(client.getOutputStream()); X !dm;
while(true) `KPTs
{ cQZs|NE&
String str=in.readLine(); q q,]5Uh0
System.out.println(str); nm+LRtK,J
out.println("has receive...."); xETDM%tZ
out.flush(); gM[;91"$
if(str.equals("end")) qZq+ =4fp
break; C|m<f`vX
} O=gHp ^
client.close(); UqFxu+QD
} iSC)G a
} :1]t:DQa
} Ss /hBj
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者