*************************************day12**************************************************
*类DatagramSocket:此类表示用来发送数据与接收数据,基于UDP协议
*DatagramSocket();创建Socket对象随机分配端口号
*DatagramSocket(int port);:创建Socket对象并指定端口号
DatagramPacket(byte[] buf, int length, InetAddress address, int port)
DatagramSocket ds=new DatagramSocket();
InetAddress address=InetAddress.getByName("PC-20171221EJAM");//ip地址
DatagramPacket dp=new DatagramPacket(b,length,address,port);
Socket sc=new Socket(InetAddress.getByName("主机名"),端口号);
OutPutStream os=sc.getOutputStream();
String str="AABBCCDDEEFFGG";***网络编程***
*类DatagramSocket:此类表示用来发送数据与接收数据,基于UDP协议
*DatagramSocket();创建Socket对象随机分配端口号
*DatagramSocket(int port);:创建Socket对象并指定端口号
DatagramPacket(byte[] buf, int length, InetAddress address, int port)
DatagramSocket ds=new DatagramSocket();
InetAddress address=InetAddress.getByName("PC-20171221EJAM");//ip地址
DatagramPacket dp=new DatagramPacket(b,length,address,port);
Socket sc=new Socket(InetAddress.getByName("主机名"),端口号);
OutPutStream os=sc.getOutputStream();
String str="AABBCCDDEEFFGG";
ServerSocket ss=new ServerSocket(10086);
InputStream is=s.getInputStream();
byte[] bys=new byte[1024];
syso(s.getIetAddress().getHostName());
System.out.println(new String(bys,0,len));
ServerSocket ss=new ServerSocket(10086);
InputStream is=s.getInputStream();
byte[] bys=new byte[1024];
syso(s.getIetAddress().getHostName());
System.out.println(new String(bys,0,len));