serverlistenthread.java

来自「本人为友邦公司做的模拟网关源代码」· Java 代码 · 共 45 行

JAVA
45
字号
package smgpgw;
import java.net.*;
/**
 * Title:        Mirco-Payment Platform
 * Description:  this is an Micro-Payment Platform implementation based on China Mobile's Micro-Payment Platform draft December, 2001
 * Copyright:    Copyright (c) 2001
 * Company:      talkweb
 * @author wangpei
 * @version 1.0
 */

public class ServerListenThread extends Thread {
	private ServerSocket mysvrsock;

	public ServerListenThread(ServerSocket svrsocket) {
		mysvrsock = svrsocket;
	}

	public void run() {
            try {
                while(true) {
                    Socket smppSocket = mysvrsock.accept();
                    try {
                        SMSCConnection sc = new SMSCConnection(smppSocket);
                        Thread scThread = new Thread (sc);
                        scThread.start() ;
                    } catch(Exception e) {
                        SMSCFrame.RecvArea.append("Create SMSC connection failed, exception : " +
                                                  e.getMessage() + "\n");
                        smppSocket.close();
                    }
                }
                // end while
            }
            catch(Exception exx) {
                try {
                        mysvrsock.close();
                } catch(Exception exxx) {}
                ;
                SMSCFrame.RecvArea.append("Create SMSC connection failed, exception : " +
                                          exx.getMessage() + "\n");
            }
	}
}

⌨️ 快捷键说明

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