class UdpSend
{
public static void main(String[] args) throws Exception
{
//1、创建UDP服务,制定要发送到的ip地址和端口
DatagramSocket ds = new DatagramSocket();
while (true)
{
//2、定义一个字节数组并打包
InputStream is = System.in;
StringBuilder sb = new StringBuilder();
while (true)
{
int ch = is.read();
if (ch=='\r')
continue;
if (ch=='\n')
{
String str = sb.toString();
byte[] buf = str.getBytes();
DatagramPacket dp =
new DatagramPacket(buf,buf.length,InetAddress.getByName("192.168.1.100"),10000);