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

📄 testclient.java

📁 采用JAVA开发
💻 JAVA
字号:
package com.gctech.sms.client;

import java.net.Socket;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.io.OutputStream;
import com.gctech.util.Tools;

/**
 * <p>Title: 短信测试客户端</p>
 * <p>Description: 短信测试客户端</p>
 * <p>Copyright: Copyright (c) 2004</p>
 * <p>Company: gctech</p>
 * @author 王红宝
 * @version $Id: TestClient.java,v 1.1 2004/05/11 06:34:39 wanghb Exp $
 */

public class TestClient {
  public TestClient() {
  }
  public static void main(String[] args) throws Exception {
    InetAddress addr = InetAddress.getByName(args[0]);
    Socket sock = new Socket(addr, Integer.parseInt(args[1]));
    OutputStream out = sock.getOutputStream();
    String msg = "汉字";
    int msgLen = msg.getBytes().length;
    int msgLength =  msgLen + 148 + 21;
    byte[] data = new byte[msgLength];
    byte[] temp = Tools.int2byte(msgLength);
    System.arraycopy(temp, 0, data, 0, 4);
    data[4] = -1;
    byte[] svcId = "FREE_AD".getBytes();
    System.arraycopy(svcId, 0, data, 5, svcId.length);
    data[25] = 2;
    data[26] = 15;
    //发送号码,可以为空
    byte[] srcTerm = "1000".getBytes();
    System.arraycopy(srcTerm, 0, data, 27, srcTerm.length);
    //计费号码
    temp = "01086073692".getBytes();
    System.arraycopy(temp, 0, data, 48, temp.length);
    data[69] = 2;
    //接收号码,和发送号码相同
    temp = "01086073692          01086073692".getBytes();
    System.arraycopy(temp, 0, data, 70, temp.length);
    int start = 126 + 21;
    data[start] = 1;
    start += 1;
    //sp编号
    temp = "testSpId".getBytes();
    System.arraycopy(temp, 0, data, start, temp.length);
    System.out.println(msgLen);
    byte[] bMsgLen = Tools.int2byte(msgLen);
    System.out.println(bMsgLen[3]);
    start += 20;
    data[start] = bMsgLen[3];
    start += 1;
    temp = msg.getBytes();
    System.arraycopy(temp, 0, data, start, temp.length);
    out.write(data);
    sock.close();
  }

}

⌨️ 快捷键说明

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