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

📄 inject.java

📁 利用hashtable实现网络广播
💻 JAVA
字号:
import java.util.*;import java.net.*;import java.io.*;public class Inject {  public static void main( String [] args ) {    int port = 0;    String msg, st, host;    Socket s;    int len;    OutputStream out;    Scanner sc;    try {      if( args.length < 3 ) {        sc = new Scanner( System.in );        System.out.print( "Enter host to connect to: " );        host = sc.nextLine();        System.out.print( "Enter port to bind on: " );        port = sc.nextInt();        sc.nextLine();        System.out.print( "Enter message: " );        msg = sc.nextLine();      } else {        host = args[0];        port = Integer.parseInt( args[1] );        msg = args[2];      }      if( ( port < 1024 ) || ( port > 32767 ) ) {        System.out.println( "Bad port specified" );        return;      }          System.out.println( "Connecting to " + host + ":" + port );      s = new Socket( host, port );      Peer.write( s, "BCAST NAP " + Peer.BCAST_INIT + " " + msg );      s.close();    } catch ( Exception e ) {      System.out.println( e );    }  }}

⌨️ 快捷键说明

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