亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? smsclistenerimpl.java

?? Short Message Peer to Peer
?? JAVA
字號:
/*
 * Copyright (c) 1996-2001
 * Logica Mobile Networks Limited
 * All rights reserved.
 *
 * This software is distributed under Logica Open Source License Version 1.0
 * ("Licence Agreement"). You shall use it and distribute only in accordance
 * with the terms of the License Agreement.
 *
 */
package org.smpp.smscsim;

import java.io.InterruptedIOException;
import java.io.IOException;

import org.smpp.SmppObject;
import org.smpp.Connection;

/**
 * This class accepts client connection on given port. When the connection
 * is accepted, the listener creates an instance of <code>SMSCSession</code>,
 * generates new <code>PDUProcessor</code> using object derived from
 * <code>PDUProcessorFactory</code>, passes the processor to the smsc session
 * and starts the session as a standalone thread.
 *
 * @author Logica Mobile Networks SMPP Open Source Team
 * @version $Revision: 1.2 $
 * @see SMSCSession
 * @see PDUProcessor
 * @see PDUProcessorFactory
 */
public class SMSCListenerImpl extends SmppObject implements Runnable, SMSCListener {
	private Connection serverConn = null;
	private int port;
	private long acceptTimeout = org.smpp.Data.ACCEPT_TIMEOUT;
	private PDUProcessorFactory processorFactory = null;
	private boolean keepReceiving = true;
	private boolean isReceiving = false;
	private boolean asynchronous = false;

	/**
	 * Construct synchronous listener listening on the given port.
	 * @param port the port to listen on
	 * @see #SMSCListenerImpl(int,boolean)
	 */
	public SMSCListenerImpl(int port) {
		this.port = port;
	}

	/**
	 * Constructor with control if the listener starts as a separate thread.
	 * If <code>asynchronous</code> is true, then the listener is started
	 * as a separate thread, i.e. the creating thread can continue after
	 * calling of method <code>start</code>. If it's false, then the
	 * caller blocks while the listener does it's work, i.e. listening.
	 * @param port the port to listen on
	 * @param asynchronous if the listening will be performed as separate thread
	 * @see #start()
	 */
	public SMSCListenerImpl(int port, boolean asynchronous) {
		this.port = port;
		this.asynchronous = asynchronous;
	}

	/**
	 * Starts the listening. If the listener is asynchronous (reccomended),
	 * then new thread is created which listens on the port and the
	 * <code>start</code> method returns to the caller. Otherwise
	 * the caller is blocked in the start method.
	 * @see #stop()
	 */
	public synchronized void start() throws IOException {
		debug.write("going to start SMSCListener on port " + port);
		if (!isReceiving) {
			serverConn = new org.smpp.TCPIPConnection(port);
			serverConn.setReceiveTimeout(getAcceptTimeout());
			serverConn.open();
			keepReceiving = true;
			if (asynchronous) {
				debug.write("starting listener in separate thread.");
				Thread serverThread = new Thread(this);
				serverThread.start();
				debug.write("listener started in separate thread.");
			} else {
				debug.write("going to listen in the context of current thread.");
				run();
			}
		} else {
			debug.write("already receiving, not starting the listener.");
		}
	}

	/**
	 * Signals the listener that it should stop listening and wait
	 * until the listener stops. Note that based on the timeout settings
	 * it can take some time befor this method is finished -- the listener
	 * can be blocked on i/o operation and only after exiting i/o
	 * it can detect that it should stop.
	 * @see #start()
	 */
	public synchronized void stop() throws IOException {
		debug.write("going to stop SMSCListener on port " + port);
		keepReceiving = false;
		while (isReceiving) {
			Thread.yield();
		}
		serverConn.close();
		debug.write("SMSCListener stopped on port " + port);
	}

	/**
	 * The actual listening code which is run either from the thread
	 * (for async listener) or called from <code>start</code> method
	 * (for sync listener). The method can be exited by calling of method
	 * <code>stop</code>.
	 * @see #start()
	 * @see #stop()
	 */
	public void run() {
		debug.enter(this, "run of SMSCListener on port " + port);
		isReceiving = true;
		try {
			while (keepReceiving) {
				listen();
				Thread.yield();
			}
		} finally {
			isReceiving = false;
		}
		debug.exit(this);
	}

	/**
	 * The "one" listen attempt called from <code>run</code> method.
	 * The listening is atomicised to allow contoled stopping of the listening.
	 * The length of the single listen attempt
	 * is defined by <code>acceptTimeout</code>.
	 * If a connection is accepted, then new session is created on this
	 * connection, new PDU processor is generated using PDU processor factory
	 * and the new session is started in separate thread.
	 * @see #run()
	 * @see com.logica.smpp.Connection
	 * @see SMSCSession
	 * @see PDUProcessor
	 * @see PDUProcessorFactory
	 */
	private void listen() {
		debug.enter(Simulator.DSIMD2, this, "SMSCListener listening on port " + port);
		try {
			Connection connection = null;
			serverConn.setReceiveTimeout(getAcceptTimeout());
			connection = serverConn.accept();

			if (connection != null) {
				debug.write("SMSCListener accepted a connection on port " + port);
				SMSCSession session = new SMSCSessionImpl(connection);
				PDUProcessor pduProcessor = null;
				if (processorFactory != null) {
					pduProcessor = processorFactory.createPDUProcessor(session);
				}
				session.setPDUProcessor(pduProcessor);
				Thread thread = new Thread(session);
				thread.start();
				debug.write("SMSCListener launched a session on the accepted connection.");
			} else {
				debug.write(Simulator.DSIMD2, "no connection accepted this time.");
			}
		} catch (InterruptedIOException e) {
			// thrown when the timeout expires => it's ok, we just didn't
			// receive anything
			debug.write("InterruptedIOException accepting, timeout? -> " + e);
		} catch (IOException e) {
			// accept can throw this from various reasons
			// and we don't want to continue then (?)
			event.write(e, "IOException accepting connection");
			keepReceiving = false;
		}
		debug.exit(Simulator.DSIMD2, this);
	}

	/**
	 * Sets a PDU processor factory to use for generating PDU processors.
	 * @param processorFactory the new PDU processor factory
	 */
	public void setPDUProcessorFactory(PDUProcessorFactory processorFactory) {
		this.processorFactory = processorFactory;
	}

	/**
	 * Sets new timeout for accepting new connection.
	 * The listening blocks the for maximum this time, then it
	 * exits regardless the connection was acctepted or not.
	 * @param value the new value for accept timeout
	 */
	public void setAcceptTimeout(int value) {
		acceptTimeout = value;
	}

	/**
	 * Returns the current setting of accept timeout.
	 * @return the current accept timeout
	 * @see #setAcceptTimeout(int)
	 */
	public long getAcceptTimeout() {
		return acceptTimeout;
	}
}
/*
 * $Log: SMSCListenerImpl.java,v $
 * Revision 1.2  2006/03/09 16:24:14  sverkera
 * Removed compiler and javadoc warnings
 *
 * Revision 1.1  2003/09/30 09:17:49  sverkera
 * Created an interface for SMSCListener and SMSCSession and implementations of them  so that it is possible to provide other implementations of these classes.
 *
 * Revision 1.1  2003/07/23 00:28:39  sverkera
 * Imported
 *
 * 
 * Old changelog:
 * 23-08-01 ticp@logica.com added yield() to run() to give chance to other
 *						    threads
 * 26-09-01 ticp@logica.com debug now in a group
 */

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品一区二区三区视频 | 一区二区三区四区在线播放| 欧美无乱码久久久免费午夜一区| 麻豆成人综合网| 亚洲人成网站色在线观看 | 亚洲视频小说图片| 欧美一级高清大全免费观看| 99re这里只有精品首页| 久久爱www久久做| 亚洲综合在线五月| 国产精品视频一二三区 | 久久亚洲综合色一区二区三区| 一本大道综合伊人精品热热| 国产成人aaaa| 韩国在线一区二区| 蜜桃久久精品一区二区| 亚洲综合色自拍一区| 国产精品电影院| 久久香蕉国产线看观看99| 欧美一区二区三区视频免费播放 | 亚洲最大成人综合| 中文字幕在线观看不卡| 久久久99精品免费观看不卡| 91精品在线免费观看| 色哟哟精品一区| 成人午夜电影网站| 国产精品一区二区在线观看网站| 日韩黄色小视频| 香蕉影视欧美成人| 亚洲成人激情综合网| 一区二区三区在线观看网站| 亚洲乱码精品一二三四区日韩在线| 国产午夜精品久久久久久免费视| 精品国产乱码久久久久久浪潮| 91精品啪在线观看国产60岁| 91精品欧美综合在线观看最新| 欧美精品一二三四| 欧美疯狂做受xxxx富婆| 欧美精品三级日韩久久| 欧美精品一卡二卡| 欧美一区二区三区在| 日韩你懂的在线播放| 亚洲精品一区二区三区蜜桃下载| 欧美成人午夜电影| 精品动漫一区二区三区在线观看| 欧美草草影院在线视频| 日韩精品在线一区| 久久久国际精品| 欧美国产日韩a欧美在线观看| 国产精品午夜免费| 中文字幕欧美一| 亚洲影院在线观看| 天堂影院一区二区| 狠狠色丁香婷婷综合| 成人污污视频在线观看| 91色.com| 欧美精品在欧美一区二区少妇| 日韩亚洲欧美中文三级| 久久亚洲精华国产精华液| 国产精品欧美一区二区三区| 亚洲黄色尤物视频| 午夜久久福利影院| 国产一区日韩二区欧美三区| 懂色av一区二区三区免费看| 91啪九色porn原创视频在线观看| 在线免费观看不卡av| 日韩丝袜情趣美女图片| 国产精品拍天天在线| 亚洲狠狠爱一区二区三区| 青青草国产成人99久久| 国产成人免费视频网站 | 国产一级精品在线| 成人白浆超碰人人人人| 欧美日韩在线直播| 精品免费国产一区二区三区四区| 国产精品久久久久久久久图文区| 亚洲国产精品久久艾草纯爱| 国产剧情一区二区| 91福利国产精品| wwww国产精品欧美| 一区二区三区欧美在线观看| 久久aⅴ国产欧美74aaa| 色综合中文字幕国产| 欧美精品1区2区3区| 国产亚洲一二三区| 亚洲一区二区精品3399| 国产福利一区在线| 欧美日韩电影在线播放| 欧美激情在线看| 日韩成人伦理电影在线观看| 91在线观看免费视频| 日韩一二三区不卡| 亚洲激情第一区| 国产成人av一区二区三区在线 | 午夜av区久久| 成人激情电影免费在线观看| 欧美高清激情brazzers| 日韩毛片一二三区| 久久9热精品视频| 欧美午夜精品久久久| 国产网站一区二区| 老鸭窝一区二区久久精品| 色综合久久久久久久久| 久久免费的精品国产v∧| 首页国产丝袜综合| 色综合久久久网| 国产精品麻豆一区二区| 国产一区二区按摩在线观看| 欧美一区二区三区免费观看视频| 亚洲精品福利视频网站| 成人免费视频国产在线观看| 久久久亚洲欧洲日产国码αv| 亚洲成人免费av| 欧美在线一区二区三区| 国产精品久久久久久福利一牛影视| 免费高清在线一区| 欧美人妖巨大在线| 亚洲成人1区2区| 色久优优欧美色久优优| 中文字幕日韩精品一区| 成人精品电影在线观看| 国产网红主播福利一区二区| 国内偷窥港台综合视频在线播放| 91精品国产综合久久国产大片 | 国产在线精品免费| 日韩欧美精品在线| 日韩—二三区免费观看av| 欧美肥妇bbw| 午夜精品在线视频一区| 538在线一区二区精品国产| 亚洲h动漫在线| 欧美日韩国产小视频| 亚洲国产日韩综合久久精品| 91福利精品视频| 午夜日韩在线观看| 欧美精品一二三| 蜜臀va亚洲va欧美va天堂| 欧美一区二区三区四区在线观看| 免费看欧美美女黄的网站| 日韩一二三四区| 国产在线视频精品一区| 国产亚洲欧美日韩日本| 国产sm精品调教视频网站| 欧美国产一区在线| 97精品国产97久久久久久久久久久久| 国产精品久久久久影视| 色婷婷亚洲精品| 亚洲综合视频在线观看| 欧美人狂配大交3d怪物一区| 蜜臀av一区二区在线观看| 精品蜜桃在线看| 成人激情校园春色| 一区二区三区国产| 欧美日本一区二区在线观看| 久久国产欧美日韩精品| 久久久久免费观看| 91视频一区二区| 视频精品一区二区| 久久久久国产免费免费| 91麻豆6部合集magnet| 首页亚洲欧美制服丝腿| 久久久国产午夜精品| 色先锋资源久久综合| 日韩国产欧美视频| 久久久久国产精品厨房| 日本高清免费不卡视频| 丝袜美腿亚洲一区二区图片| 久久久国产午夜精品| 欧美性三三影院| 国产在线播放一区| 亚洲欧美日韩中文字幕一区二区三区| 欧洲亚洲精品在线| 精油按摩中文字幕久久| 一色屋精品亚洲香蕉网站| 制服丝袜亚洲网站| 国产精品一级二级三级| 亚洲激情图片qvod| 欧美精品一区二区三| 91麻豆福利精品推荐| 麻豆精品一区二区av白丝在线| 国产精品久久久久一区二区三区 | 一区二区三区av电影| 日韩亚洲欧美成人一区| 99久久免费国产| 美女爽到高潮91| 亚洲美女屁股眼交| 久久综合色婷婷| 色婷婷久久一区二区三区麻豆| 韩国成人精品a∨在线观看| 亚洲主播在线播放| 国产亚洲欧美在线| 6080亚洲精品一区二区| 97久久超碰国产精品| 国产一区二区调教| 天天综合天天综合色| 国产精品拍天天在线| 久久影院午夜论| 91精品在线麻豆| 在线一区二区三区| 成人中文字幕合集|