有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

如何断开Java中已使用的端口

我想断开此代码使用的端口

public class TestSMS {

    private static String port = "COM10"; //Modem Port.
    private static int bitRate = 115200; //this is also optional. leave as it is.
    private static String modemName = "ZTE"; //this is optional.
    private static String modemPin = "0000"; //Pin code if any have assigned to the modem.
    private static String SMSC = "+000000"; //Message Center Number 

    public static void main(String[] args) throws Exception {
        for (int i = 0; i < 5; i++) {

            try {
                GsmModem gsmModem = new GsmModem();
                gsmModem.configModem(port, bitRate, modemName, modemPin, SMSC);
                gsmModem.Sender("00000000", "Test Message"); // (tp, msg)

            } 
            catch (Exception e) {
            }


我想从COM端口10断开此连接,请帮助我


共 (1) 个答案