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

📄 infodatagramme.java

📁 exemple for using java chat client + server
💻 JAVA
字号:
/*
 * Infodatagramme.java
 *
 * Created on 12 novembre 2008, 11:40
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package UDP;
import java.net.*;
/**
 *
 * @author Administrateur
 */
public class Infodatagramme {
    
    /** Creates a new instance of Infodatagramme */
    public Infodatagramme() {
    }
    public static void main(String args[])
    {
        String s ="hello";
        byte[] donnees =s.getBytes();
        try
        {
            InetAddress id =InetAddress.getByName("www.google.com");
            int port = 7;
            DatagramPacket dp = new DatagramPacket(donnees,donnees.length,id,port);
            System.out.println("Ce paquet est adresse a"+dp.getAddress().getHostAddress()+"sur le port"
                    +dp.getPort());
            System.out.println("Il comporte "+dp.getLength()+"octects de donnees ");
            System.out.println(new String (dp.getData(),dp.getOffset(),dp.getLength()));
        }
        catch(UnknownHostException e)
        {
            System.err.println(e.getMessage());
        }
    }
}

⌨️ 快捷键说明

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