package Day32_Net;
import java.io.IOException;
import java.net.*;
import java.util.Scanner;
/**
* @Author quzheng
* @Date 2019/10/6 16:38
* @Version 1.0
*/
public class UDP_ScannerTalk {
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
DatagramSocket ds = new DatagramSocket();
InetAddress inet = InetAddress.getByName("127.0.0.1");
while (true){
String s = sc.nextLine();
byte[] date = s.getBytes();
DatagramPacket dp = new DatagramPacket(date,date.length,inet,6000);
ds.send(dp);
}
// ds.close();
}
}
网友评论