?? multicastclient.java
字號:
// ==================== Program Discription =====================
// 程序名稱:示例12-13: MulticastClient.java
// 程序目的:UDP組播客戶端。
//=========================================================
import java.io.*;
import java.net.*;
import java.util.*;
public class MulticastClient
{
public static void main(String[] args) throws IOException
{
MulticastSocket socket = new MulticastSocket(4446);
InetAddress address = InetAddress.getByName("136.122.133.1");
socket.joinGroup(address);
DatagramPacket packet;
for (int i = 0; i < 5; i++)
{
byte[] buf = new byte[256];
packet = new DatagramPacket(buf, buf.length);
socket.receive(packet);
String received = new String(packet.getData());
System.out.println("Quote of the Moment: " + received);
}
socket.leaveGroup(address);
socket.close();
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -