parent
3e24cdd80f
commit
ee9dc0a979
@ -0,0 +1,18 @@
|
|||||||
|
package 发送接收数据;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.*;
|
||||||
|
|
||||||
|
public class sendMessage {
|
||||||
|
public static void main(String[] args) throws IOException {
|
||||||
|
DatagramSocket ds=new DatagramSocket();
|
||||||
|
String str="你好啊";
|
||||||
|
byte[] bytes=str.getBytes();
|
||||||
|
InetAddress address=InetAddress.getByName("127.0.0.1");
|
||||||
|
int port=10086;
|
||||||
|
DatagramPacket dp=new DatagramPacket(bytes,bytes.length,address,port);
|
||||||
|
ds.send(dp);
|
||||||
|
ds.close();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue