⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dgmrecv.java

📁 client server using socket programing with best optimized way to do .. and how to do guide is als
💻 JAVA
字号:
// DgmRecv.java receives a little UDP message via DatagramPacket

import java.net.*;
import java.io.*;

public class DgmRecv
{
  static final int PORT = 3030;
  
  static final int BUF_SIZE = 128;  // arbitrary size

  public static void main(String[] args)
    throws Exception
  {
    DatagramSocket sock = new DatagramSocket(PORT);
    byte[] buf = new byte[BUF_SIZE];
    DatagramPacket pack= new DatagramPacket(buf, buf.length);

    System.out.println( "DgmRecv listener ready" );
    
    sock.receive(pack);

    System.out.println( new String(buf, 0, pack.getLength()) );
    System.out.println( " from " + pack.getAddress() );
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -