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

📄 taskencoder.java

📁 利用Java Socket写的一段通讯协议
💻 JAVA
字号:
package com.ict.netcom2.trash;

import java.io.*;

public class TaskEncoder {

    public static byte[] encodeHttpRefTask(long testTimes, int port,
    		int interval, int protoType, String url) {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        DataOutputStream dos = new DataOutputStream(baos);        
        try {        	
            dos.writeInt((int)(testTimes));
            dos.writeShort(url.length());
            dos.writeShort(port);
            dos.writeShort(interval);
            dos.writeShort(protoType);
            dos.writeBytes(url);
            dos.close();
            baos.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return baos.toByteArray();
    }
    
    public static byte[] encodePasvEth() {
    	byte[] b= {1, 0, 1, 0, 0, 0, 0, 2, 60, 0, 1, 2, 3, 4, 5};
    	return b;
    }

    public static void main(String[] args) {
    	//long l = 0x0ffffffffl;
    	//char c = 0xffff;
    	
    	byte[] b = encodeHttpRefTask(
    			0x0ffffffffl, 0x50, 0x0ffff, 0x0ffffff, "www.google.com");
    	
    	for (int i=0; i<b.length; i++)
    		System.out.println((int)b[i]);   	
    	
    }
}

⌨️ 快捷键说明

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