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

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

?? tcpipconnection.java

?? Short Message Peer to Peer
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
/*
 * 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;

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产剧情在线观看一区二区| 久久精品一区二区三区不卡| 一区二区三区鲁丝不卡| 99久久精品免费精品国产| 亚洲欧洲精品一区二区三区| 色94色欧美sute亚洲线路一ni| 亚洲色图欧美在线| 色婷婷av一区二区三区软件 | 国模娜娜一区二区三区| 欧美岛国在线观看| 韩国一区二区三区| 欧美国产精品一区二区| www.欧美亚洲| 一区二区在线观看免费视频播放| 欧美亚洲高清一区| 水野朝阳av一区二区三区| 久久亚洲二区三区| 99久久国产综合精品色伊| 亚洲自拍另类综合| 精品美女在线观看| 91亚洲精品乱码久久久久久蜜桃 | 一区二区三区在线观看欧美| 欧美色区777第一页| 日韩有码一区二区三区| 国产亚洲婷婷免费| 在线观看91视频| 激情偷乱视频一区二区三区| 国产欧美日韩综合精品一区二区| 色综合久久久久综合| 久久国产福利国产秒拍| 亚洲男同性视频| 欧美一区二区三区四区视频| 国产精品一色哟哟哟| 一区二区欧美视频| 久久久久久亚洲综合| 91亚洲精华国产精华精华液| 美女国产一区二区三区| 亚洲欧美乱综合| 欧美精品一区二区三区四区| 色婷婷av一区二区三区大白胸 | 欧美国产日韩亚洲一区| 在线观看国产精品网站| 国产一区二区视频在线播放| 亚洲综合丝袜美腿| 久久精品视频免费观看| 91麻豆精品国产91久久久久久久久 | 91视频精品在这里| 久久精品国产久精国产| 一区二区三区欧美久久| 2021国产精品久久精品| 欧美日韩午夜精品| 99久久er热在这里只有精品15| 久久精工是国产品牌吗| 亚洲乱码国产乱码精品精小说| 久久久精品国产99久久精品芒果| 91精品国产综合久久蜜臀| 91在线你懂得| 成人精品免费看| 国产一区二区主播在线| 麻豆精品视频在线观看| 亚洲国产成人91porn| 亚洲欧美色一区| 综合欧美一区二区三区| 久久精品无码一区二区三区| 2021中文字幕一区亚洲| 久久先锋影音av| 精品国偷自产国产一区| 91精品国产91热久久久做人人| 欧美唯美清纯偷拍| 欧美制服丝袜第一页| 在线观看视频欧美| 成人短视频下载| eeuss鲁片一区二区三区在线看| 丰满岳乱妇一区二区三区| 精品一区二区三区香蕉蜜桃 | 国产成人综合在线| 国产一区日韩二区欧美三区| 久久精品国产99国产精品| 日本91福利区| 久久99久久99精品免视看婷婷 | 亚洲主播在线观看| 一区二区三区中文字幕精品精品| 国产精品初高中害羞小美女文| 中文字幕 久热精品 视频在线| 国产喷白浆一区二区三区| 久久久国产午夜精品 | 国产精品美女一区二区在线观看| 久久久亚洲精华液精华液精华液| 精品国产1区二区| 26uuu成人网一区二区三区| 久久久久亚洲蜜桃| 国产精品久久久99| 亚洲激情一二三区| 亚洲成va人在线观看| 免费看日韩a级影片| 激情图片小说一区| av一二三不卡影片| 欧美亚洲国产bt| 日韩精品一区二区三区视频 | www国产成人| 国产欧美一区二区精品仙草咪| 国产精品久久久久三级| 亚洲免费毛片网站| 男人的j进女人的j一区| 国产美女av一区二区三区| 成人高清视频免费观看| 在线免费视频一区二区| 欧美大尺度电影在线| 国产精品系列在线| 亚洲不卡av一区二区三区| 久久精工是国产品牌吗| 99久久精品99国产精品| 欧美一区二区三区色| 日本一区二区视频在线| 一区二区三区加勒比av| 久色婷婷小香蕉久久| 99精品一区二区三区| 欧美一区二区啪啪| 国产精品全国免费观看高清| 亚洲成av人**亚洲成av**| 国产精品小仙女| 欧美人狂配大交3d怪物一区| 久久久久久久久久久黄色| 一区二区高清免费观看影视大全| 美国十次了思思久久精品导航| 成人福利在线看| 精品国产三级电影在线观看| 亚洲免费在线播放| 国产盗摄视频一区二区三区| 欧美三级韩国三级日本一级| 久久精品夜色噜噜亚洲aⅴ| 亚洲高清免费观看| 成人精品鲁一区一区二区| 日韩欧美另类在线| 亚洲精品v日韩精品| 国产精品18久久久久久久久| 在线综合亚洲欧美在线视频| 亚洲激情五月婷婷| 国产乱妇无码大片在线观看| 欧美一区二区三区思思人| 亚洲综合久久久| av亚洲精华国产精华精| 久久久久久亚洲综合| 美女尤物国产一区| 欧美日韩国产免费一区二区| 日韩码欧中文字| 国产一区二区久久| 日韩精品中文字幕在线不卡尤物| 亚洲永久精品大片| 色综合久久久久综合| 国产精品系列在线| 高清beeg欧美| 久久噜噜亚洲综合| 国产精品自拍av| 精品国产91洋老外米糕| 美女国产一区二区| 日韩视频免费观看高清完整版| 亚洲国产精品久久人人爱| 色素色在线综合| 亚洲同性gay激情无套| 成人网在线播放| 国产日韩av一区二区| 国产成人av影院| 国产日韩精品一区二区三区| 国产专区综合网| 久久久www成人免费毛片麻豆 | 国产精品美日韩| 春色校园综合激情亚洲| 欧美国产精品久久| 成人v精品蜜桃久久一区| 国产精品网站在线| 国产69精品久久久久777| 欧美激情艳妇裸体舞| 成人avav在线| 亚洲日本一区二区三区| 在线精品视频小说1| 亚洲综合在线观看视频| 欧美日韩一级二级三级| 五月婷婷久久综合| 日韩欧美一二三| 国产精品1区2区| 国产精品看片你懂得| 91香蕉视频mp4| 亚洲小说欧美激情另类| 欧美一区二区在线观看| 国产精品18久久久久久久久 | 91丨porny丨最新| 亚洲情趣在线观看| 欧美日韩国产片| 国产美女精品在线| 亚洲男同性视频| 欧美一区二区三区四区久久| 国产精品88av| 亚洲最大成人综合| 日韩免费一区二区| 99久久婷婷国产| 日日摸夜夜添夜夜添国产精品| 精品久久久影院| 色综合色综合色综合| 免费在线观看不卡|