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

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

?? tcpipconnection.java

?? Short Message Peer to Peer
?? JAVA
?? 第 1 頁(yè) / 共 2 頁(yè)
字號(hào):
/*
 * 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;

import org.smpp.util.*;

import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketException;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.EOFException;
import java.io.IOException;
import java.io.InterruptedIOException;

import javax.net.ServerSocketFactory;
import javax.net.SocketFactory;

/**
 * Implementation of TCP/IP type of communication.
 * Covers both client (peer-to-peer) connection and server (new connections
 * from clients accepting and creating) type of connections.
 * 
 * @author Logica Mobile Networks SMPP Open Source Team
 * @version $Revision: 1.3 $
 * @see Connection
 * @see java.net.Socket
 * @see java.net.ServerSocket
 * @see java.io.BufferedInputStream
 * @see java.io.BufferedOutputStream
 */
public class TCPIPConnection extends Connection {
	/**
	 * The IP address of the remote end of the <code>socket</code>. 
	 */
	private String address = null;

	/**
	 * The port number on the remote host to which the <code>socket</code>
	 * is connected or port number where <code>receiverSocket</code>
	 * is acception connections.
	 */
	private int port = 0;

	/**
	 * The TCP/IP (client) socket.
	 *
	 * @see java.net.Socket
	 */
	private Socket socket = null;

	/**
	 * An input stream for reading bytes from the <code>socket</code>.
	 *
	 * @see java.io.BufferedInputStream
	 */
	private BufferedInputStream inputStream = null;

	/**
	 * An output stream for writting bytes to the <code>socket</code>.
	 *
	 * @see java.io.BufferedOutputStream
	 */
	private BufferedOutputStream outputStream = null;

	/**
	 * Indication if the <code>socket</code> is opened.
	 */
	private boolean opened = false;

	/**
	 * The server socket used for accepting connection on <code>port</code>.
	 *
	 * @see #port
	 * @see java.net.ServerSocket
	 */
	private ServerSocket receiverSocket = null;

	/**
	 * Indicates if the connection represents client or server socket.
	 */
	private byte connType = CONN_NONE;

	/**
	 * Indicates that the connection type hasn't been set yet.
	 */
	private static final byte CONN_NONE = 0;

	/**
	 * Indicates that the connection is client type connection.
	 * @see #socket
	 */
	private static final byte CONN_CLIENT = 1;

	/**
	 * Indicates that the connection is server type connection.
	 * @see #receiverSocket
	 */
	private static final byte CONN_SERVER = 2;

	/**
	 * Default size for socket io streams buffers.
	 * @see #initialiseIOStreams(Socket)
	 */
	private static final int DFLT_IO_BUF_SIZE = 2 * 1024;

	/**
	 * Default size for the receiving buffer.
	 */
	private static final int DFLT_RECEIVE_BUFFER_SIZE = 4 * 1024;

	/**
	 * The default maximum of bytes received in one call to
	 * the <code>receive</code> function.
	 * @see #maxReceiveSize
	 * @see #receive()
	 */
	private static final int DFLT_MAX_RECEIVE_SIZE = 128 * 1024;

	/**
	 * The size for IO stream's buffers. Used by the instances of 
	 * <code>BufferedInputStream</code> which are used as sreams for accessing
	 * the socket.
	 * @see #setIOBufferSize(int)
	 */
	private int ioBufferSize = DFLT_IO_BUF_SIZE;

	/**
	 * The receiver buffer size. Can be changed by call to the function
	 * <code>setReceiveBufferSize</code>. This is the maximum count of bytes
	 * which can be read from the socket in one call to the socket's
	 * input stream's <code>read</code>.
	 * @see #setReceiveBufferSize(int)
	 * @see #receive()
	 */
	private int receiveBufferSize;

	/**
	 * The buffer for storing of received data in the <code>receive</code>
	 * function. 
	 * @see #setReceiveBufferSize(int)
	 * @see #receive()
	 */
	private byte[] receiveBuffer;

	/**
	 * Max count of bytes which can be returned from one call
	 * to the <code>receive</code> function. If the returned data seems
	 * to be incomplete, you might want to call the <code>receive</code> again.
	 * @see #setMaxReceiveSize(int)
	 * @see #receive()
	 */
	private int maxReceiveSize = DFLT_MAX_RECEIVE_SIZE;

	/**
	 * Instanciate a SocketFactory which will be used to create sockets later.
	 * Subclasses can override this field with e.g. a SSLSocketFactory
	 */
	protected SocketFactory socketFactory = SocketFactory.getDefault();

	/**
	 * Instanciate a ServerSocketFactory which will be used to create server sockets later.
	 * Subclasses can override this field with e.g. a SSLServerSocketFactory
	 */
	protected ServerSocketFactory serverSocketFactory = ServerSocketFactory.getDefault();
	
	/**
	 * Initialises the connection with port only, which means that
	 * the connection will serve as connection receiving server.
	 * The accepting of the connection must be invoked explicitly by
	 * calling of <code>accept</code> method.
	 *
	 * @param port the port number to listen on
	 */
	public TCPIPConnection(int port) {
		if ((port >= Data.MIN_VALUE_PORT) && (port <= Data.MAX_VALUE_PORT)) {
			this.port = port;
		} else {
			debug.write("Invalid port.");
		}
		connType = CONN_SERVER;
	}

	/**
	 * Initialises the connection for client communication.
	 *
	 * @param address  the address of the remote end
	 *                 of the <code>socket</code>
	 * @param port     the port number on the remote host
	 */
	public TCPIPConnection(String address, int port) {
		if (address.length() >= Data.MIN_LENGTH_ADDRESS) {
			this.address = address;
		} else {
			debug.write("Invalid address.");
		}
		if ((port >= Data.MIN_VALUE_PORT) && (port <= Data.MAX_VALUE_PORT)) {
			this.port = port;
		} else {
			debug.write("Invalid port.");
		}
		connType = CONN_CLIENT;
		setReceiveBufferSize(DFLT_RECEIVE_BUFFER_SIZE);
	}

	/**
	 * Initialises the connection with existing socket.
	 * It's intended for use with one server connection which generates
	 * new sockets and creates connections with the sockets.
	 *
	 * @param socket the socket to use for communication
	 * @see #accept()
	 */
	public TCPIPConnection(Socket socket) throws IOException {
		connType = CONN_CLIENT;
		this.socket = socket;
		address = socket.getInetAddress().getHostAddress();
		port = socket.getPort();
		initialiseIOStreams(socket);
		opened = true;
		setReceiveBufferSize(DFLT_RECEIVE_BUFFER_SIZE);
	}

	/**
	 * Opens the connection by creating new <code>Socket</code> (for client
	 * type connection) or by creating <code>ServerSocket</code> (for
	 * server type connection). If the connection is already opened,
	 * the method is not doing anything.
	 *
	 * @see #connType
	 * @see java.net.ServerSocket
	 * @see java.net.Socket
	 */
	public void open() throws IOException {
		debug.enter(DCOM, this, "open");
		IOException exception = null;

		if (!opened) {
			if (connType == CONN_CLIENT) {
				try {
					socket = socketFactory.createSocket(address, port);
					initialiseIOStreams(socket);
					opened = true;
					debug.write(DCOM, "opened client tcp/ip connection to " + address + " on port " + port);
				} catch (IOException e) {
					debug.write("IOException opening TCPIPConnection " + e);
					event.write(e, "IOException opening TCPIPConnection");
					exception = e;
				}
			} else if (connType == CONN_SERVER) {
				try {
					receiverSocket = serverSocketFactory.createServerSocket(port);
					opened = true;
					debug.write(DCOM, "listening tcp/ip on port " + port);
				} catch (IOException e) {
					debug.write("IOException creating listener socket " + e);
					exception = e;
				}
			} else {
				debug.write("Unknown connection type = " + connType);
			}
		} else {
			debug.write("attempted to open already opened connection ");
		}

		debug.exit(DCOM, this);
		if (exception != null) {
			throw exception;
		}
	}

	/**
	 * Closes the client or server connection.
	 *
	 * @see #connType
	 * @see #open()
	 */
	public void close() throws IOException {
		debug.enter(DCOM, this, "close");
		IOException exception = null;

		if (connType == CONN_CLIENT) {
			try {
				if(inputStream != null)
					inputStream.close();
				if(outputStream != null)
					outputStream.close();
				if(socket != null)
					socket.close();
				inputStream = null;
				outputStream = null;
				socket = null;

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日日摸夜夜添夜夜添精品视频| av电影天堂一区二区在线| 亚洲最快最全在线视频| 久久精品视频免费| 2021中文字幕一区亚洲| 欧美不卡一区二区| 欧美成人r级一区二区三区| 日韩三级.com| 精品国产一区二区亚洲人成毛片| 日韩一区二区三| 精品国产免费视频| 久久久久久久久久美女| 久久久国产一区二区三区四区小说| 欧美videossexotv100| 久久久久国产精品人| 亚洲国产高清aⅴ视频| 欧美国产一区在线| 中文字幕视频一区二区三区久| 亚洲日本韩国一区| 亚洲大片在线观看| 久久精品国产在热久久| 国产综合色在线视频区| 成人精品亚洲人成在线| 色老头久久综合| 欧美伦理视频网站| 日韩精品中文字幕一区| 久久久国产午夜精品| 综合自拍亚洲综合图不卡区| 亚洲国产精品久久久男人的天堂| 日韩精品1区2区3区| 国产乱码精品一区二区三区五月婷| 国产麻豆视频一区二区| 色又黄又爽网站www久久| 欧美一区二区三区婷婷月色| 国产日韩欧美麻豆| 成人免费在线播放视频| 五月激情综合网| 国产精品99久久久久久久vr | 日本怡春院一区二区| 经典三级在线一区| www.激情成人| 欧美日韩情趣电影| 久久久精品日韩欧美| 亚洲精品欧美激情| 久草热8精品视频在线观看| www.亚洲色图| 欧美一区二区三区思思人| 欧美极品美女视频| 亚洲成人午夜影院| 粉嫩蜜臀av国产精品网站| 在线视频你懂得一区| 日韩片之四级片| 亚洲视频在线一区观看| 久久99九九99精品| 91福利区一区二区三区| 久久精品人人做人人爽人人| 亚洲一区二区视频在线| 国产精品乡下勾搭老头1| 欧美日韩日日骚| 中文字幕五月欧美| 麻豆精品久久久| 欧美一卡2卡3卡4卡| 最近日韩中文字幕| 国产精品亚洲视频| 91精品国产综合久久福利| 亚洲欧美另类综合偷拍| 国产一二精品视频| 欧美理论片在线| 中文字幕一区二区在线播放| 精品一二三四在线| 3atv一区二区三区| 亚洲国产一区在线观看| eeuss影院一区二区三区| 久久一留热品黄| 奇米色777欧美一区二区| 日本高清无吗v一区| 中文字幕免费在线观看视频一区| 美女一区二区久久| 777奇米成人网| 亚洲激情在线播放| a级精品国产片在线观看| 久久亚洲二区三区| 久久精品噜噜噜成人88aⅴ| 欧美日韩1区2区| 亚洲精品欧美激情| 91香蕉视频污| 亚洲欧美在线视频| 岛国一区二区三区| 久久久久九九视频| 狠狠久久亚洲欧美| 日韩欧美三级在线| 日本va欧美va精品发布| 884aa四虎影成人精品一区| 一区2区3区在线看| 色综合av在线| 洋洋成人永久网站入口| 91香蕉视频污| 亚洲欧美另类在线| 色呦呦日韩精品| 一区二区三区在线观看视频 | 精品粉嫩aⅴ一区二区三区四区| 亚洲国产日韩一级| 欧美中文字幕一区二区三区| 一二三四区精品视频| 色老头久久综合| 亚洲aⅴ怡春院| 777精品伊人久久久久大香线蕉| 午夜av一区二区三区| 91精品国产手机| 麻豆精品在线视频| 日韩一卡二卡三卡四卡| 久久99精品网久久| 国产欧美一区二区三区在线老狼 | 7777精品伊人久久久大香线蕉完整版 | 成人精品视频网站| 中文字幕在线观看一区| 成人高清免费在线播放| 一区二区三区在线高清| 99re6这里只有精品视频在线观看| 国产精品女主播在线观看| 91一区二区在线观看| 亚洲综合色网站| 欧美日韩久久久一区| 奇米四色…亚洲| 国产无一区二区| 99久久精品免费| 午夜不卡在线视频| 日韩视频免费直播| 国产成人精品综合在线观看| 看电影不卡的网站| 国产亚洲视频系列| eeuss影院一区二区三区| 亚洲图片欧美视频| 精品国产乱码久久久久久夜甘婷婷| 国产成人久久精品77777最新版本| 亚洲丝袜制服诱惑| 欧美日本在线看| 国产乱码字幕精品高清av | 亚洲精品久久久蜜桃| 在线观看免费亚洲| 理论片日本一区| 中文字幕综合网| 欧美日韩第一区日日骚| 国产一区二区不卡| 一区二区三区在线免费| 精品国产第一区二区三区观看体验| 成人黄页毛片网站| 综合久久综合久久| 4438成人网| 成人综合日日夜夜| 天使萌一区二区三区免费观看| 久久综合九色综合欧美亚洲| 91美女在线观看| 久久99精品久久只有精品| 亚洲女同女同女同女同女同69| 日韩丝袜情趣美女图片| av电影一区二区| 精品一区二区在线播放| 亚洲免费在线观看视频| www激情久久| 欧美日韩在线电影| 国产v日产∨综合v精品视频| 日韩国产精品久久久久久亚洲| 欧美激情在线一区二区| 欧美少妇一区二区| 国产成人免费在线视频| 亚洲午夜一区二区| 国产精品美日韩| 在线成人免费视频| caoporn国产精品| 美女网站一区二区| 亚洲一区二区免费视频| 国产欧美精品日韩区二区麻豆天美| 欧美精品一二三| 日本精品裸体写真集在线观看| 韩国精品久久久| 青青国产91久久久久久| 一区二区三区在线免费播放| 国产欧美一二三区| 精品久久国产字幕高潮| 欧美欧美欧美欧美| 色婷婷久久久综合中文字幕| 成人听书哪个软件好| 国产一区二区三区四区五区美女| 日日骚欧美日韩| 午夜欧美电影在线观看| 亚洲尤物视频在线| 自拍偷在线精品自拍偷无码专区| 久久这里只有精品6| 欧美一区二区私人影院日本| 精品视频免费看| 91亚洲男人天堂| 97成人超碰视| 丁香婷婷深情五月亚洲| 国产乱国产乱300精品| 久久精品国内一区二区三区| 免费观看成人av| 毛片一区二区三区| 美女在线视频一区| 久久aⅴ国产欧美74aaa|