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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? tcpipconnection.java

?? Short Message Peer to Peer
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
				opened = false;
				debug.write(DCOM, "closed client tcp/ip connection to " + address + " on port " + port);
			} catch (IOException e) {
				debug.write("IOException closing socket " + e);
				event.write(e, "IOException closing socket");
				exception = e;
			}
		} else if (connType == CONN_SERVER) {
			try {
				if(receiverSocket != null)
					receiverSocket.close();
				receiverSocket = null;
				opened = false;
				debug.write(DCOM, "stopped listening tcp/ip on port " + port);
			} catch (IOException e) {
				debug.write("IOException closing listener socket " + e);
				event.write(e, "IOException closing listener socket");
				exception = e;
			}
		} else {
			debug.write("Unknown connection type = " + connType);
		}

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

	/**
	 * Sends data over the connection. Must be client type connection.
	 * The timeout for sending is set by <code>setCommsTimeout</code>.
	 *
	 * @see java.net.Socket
	 */
	public void send(ByteBuffer data) throws IOException {
		debug.enter(DCOM, this, "send");
		IOException exception = null;

		if (outputStream == null) {
			debug.exit(DCOM, this);
			throw new IOException("Not connected");
		}
		if (connType == CONN_CLIENT) {
			try {
				socket.setSoTimeout((int) getCommsTimeout());
				try {
					outputStream.write(data.getBuffer(), 0, data.length());
					debug.write(DCOM, "sent " + data.length() + " bytes to " + address + " on port " + port);
				} catch (IOException e) {
					debug.write("IOException sending data " + e);
					exception = e;
				}
				outputStream.flush();
			} catch (IOException e) {
				debug.write("IOException flushing data " + e);
				if (exception == null) {
					exception = e;
				}
			}
		} else if (connType == CONN_SERVER) {
			debug.write("Attempt to send data over server type connection.");
		} else {
			debug.write("Unknown connection type = " + connType);
		}

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

	}

	/**
	 * Reads data from the connection. Must be client type connection.
	 * The timeout for receiving is set by <code>setReceiveTimeout</code>.
	 * The timeout for single attempt to read something from socket is 
	 * set by <code>setCommsTimeout</code>.
	 *
	 * @see #setReceiveBufferSize(int)
	 * @see #setMaxReceiveSize(int)
	 * @see Connection#getCommsTimeout()
	 * @see java.net.Socket
	 */
	public ByteBuffer receive() throws IOException {
		debug.enter(DCOMD, this, "receive");
		IOException exception = null;

		ByteBuffer data = null;
		if (connType == CONN_CLIENT) {
			data = new ByteBuffer();
			long endTime = Data.getCurrentTime() + getReceiveTimeout();
			//int bytesAvailable = 0;
			int bytesToRead = 0;
			int bytesRead = 0;
			int totalBytesRead = 0;

			try {
				socket.setSoTimeout((int) getCommsTimeout());
				bytesToRead = receiveBufferSize;
				debug.write(DCOMD, "going to read from socket");
				debug.write(
					DCOMD,
					"comms timeout="
						+ getCommsTimeout()
						+ " receive timeout="
						+ getReceiveTimeout()
						+ " receive buffer size="
						+ receiveBufferSize);
				do {
					bytesRead = 0;
					try {
						bytesRead = inputStream.read(receiveBuffer, 0, bytesToRead);
					} catch (InterruptedIOException e) {
						// comms read timeout expired, no problem
						debug.write(DCOMD, "timeout reading from socket");
					}
					if (bytesRead > 0) {
						debug.write(DCOMD, "read " + bytesRead + " bytes from socket");
						data.appendBytes(receiveBuffer, bytesRead);
						totalBytesRead += bytesRead;
					}
					if (bytesRead == -1) {
						debug.write(DCOMD, "reached end of stream");
						close();
						throw new EOFException("Reached end of stream");
					}

					bytesToRead = inputStream.available();
					if (bytesToRead > 0) {
						debug.write(DCOMD, "more data (" + bytesToRead + " bytes) remains in the socket");
					} else {
						debug.write(DCOMD, "no more data remains in the socket");
					}
					if (bytesToRead > receiveBufferSize) {
						bytesToRead = receiveBufferSize;
					}
					if (totalBytesRead + bytesToRead > maxReceiveSize) {
						// would be more than allowed
						bytesToRead = maxReceiveSize - totalBytesRead;
					}
				} while (
					((bytesToRead != 0) && (Data.getCurrentTime() <= endTime)) && (totalBytesRead < maxReceiveSize));

				debug.write(DCOM, "totally read " + data.length() + " bytes from socket");
			} catch (IOException e) {
				debug.write("IOException: " + e.getMessage());
				event.write(e, "IOException receive via TCPIPConnection");
				exception = e;
				close();
			}
		} else if (connType == CONN_SERVER) {
			debug.write("Attempt to receive data from server type connection.");
		} else {
			debug.write("Unknown connection type = " + connType);
		}

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

	/**
	 * Accepts new connection on server type connection, i.e. on ServerSocket.
	 * If new socket is returned from ServerSocket.accept(), creates new
	 * instance of TCPIPConnection with the new socket and returns it,
	 * otherwise returns null. The timeout for new connection accept is
	 * set by <code>setReceiveTimeout</code>, i.e. waits for new connection
	 * for this time and then, if none is requested, returns with null.
	 *
	 * @see #TCPIPConnection(Socket)
	 * @see java.net.ServerSocket#accept()
	 * @see java.net.ServerSocket#setSoTimeout(int)
	 */
	public Connection accept() throws IOException {
		debug.enter(DCOMD, this, "receive");
		IOException exception = null;

		Connection newConn = null;
		if (connType == CONN_SERVER) {
			try {
				receiverSocket.setSoTimeout((int) getReceiveTimeout());
			} catch (SocketException e) {
				// don't care, we're just setting the timeout
			}
			Socket acceptedSocket = null;
			try {
				acceptedSocket = receiverSocket.accept();
			} catch (IOException e) {
				debug.write(DCOMD, "Exception accepting socket (timeout?)" + e);
			}
			if (acceptedSocket != null) {
				try {
					newConn = new TCPIPConnection(acceptedSocket);
				} catch (IOException e) {
					debug.write("IOException creating new client connection " + e);
					event.write(e, "IOException creating new client connection");
					exception = e;
				}
			}
		} else if (connType == CONN_CLIENT) {
			debug.write("Attempt to receive data from client type connection.");
		} else {
			debug.write("Unknown connection type = " + connType);
		}

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

	/**
	 * Initialises input and output streams to the streams from socket
	 * for client type connection.
	 * Streams are used for sending and receiving data from the socket.
	 *
	 * @see #inputStream
	 * @see #outputStream
	 * @see java.net.Socket#getInputStream()
	 * @see java.net.Socket#getOutputStream()
	 */
	private void initialiseIOStreams(Socket socket) throws IOException {
		if (connType == CONN_CLIENT) {
			inputStream = new BufferedInputStream(socket.getInputStream(), ioBufferSize);
			outputStream = new BufferedOutputStream(socket.getOutputStream(), ioBufferSize);
		} else if (connType == CONN_SERVER) {
			debug.write("Attempt to initialise i/o streams for server type connection.");
		} else {
			debug.write("Unknown connection type = " + connType);
		}
	}

	/**
	 * Sets the size for the io buffers of streams for accessing the socket.
	 * The size can only be changed before actual opening of the connection.
	 * @see #initialiseIOStreams(Socket)
	 */
	public void setIOBufferSize(int ioBufferSize) {
		if (!opened) {
			this.ioBufferSize = ioBufferSize;
		}
	}

	/**
	 * Sets the size of the receiving buffer, which is used for reading from
	 * the socket. A buffer of this size is allocated for the reading.
	 * @see #receive()
	 */
	public void setReceiveBufferSize(int receiveBufferSize) {
		this.receiveBufferSize = receiveBufferSize;
		receiveBuffer = new byte[receiveBufferSize];
	}

	/**
	 * Sets the maximum size of the data which can be read in one call to
	 * the <code>receive</code> function. After reading of this amount
	 * of bytes the receive returns the data read even if there are more data
	 * in the socket.
	 * @see #receive()
	 */
	public void setMaxReceiveSize(int maxReceiveSize) {
		this.maxReceiveSize = maxReceiveSize;
	}

	/**
	 * @see org.smpp.Connection#isOpened()
	 */
	public boolean isOpened() {
		return opened;
	}
}
/*
 * $Log: TCPIPConnection.java,v $
 * Revision 1.3  2004/09/10 23:02:59  sverkera
 * Use SocketFactory, and some changes to eliminate NullPointerException
 *
 * Revision 1.2  2003/12/16 14:47:20  sverkera
 * Added a close when reaching end-of-stream
 *
 * Revision 1.1  2003/07/23 00:28:39  sverkera
 * Imported
 *
 * 
 * Old changelog:
 * 26-09-01 ticp@logica.com debug code categorized to groups
 * 27-09-01 ticp@logica.com receive() rewritten not to consume cpu time while
 *						    waiting for data on socket
 * 27-09-01 ticp@logica.com added customizable limit on maximum received bytes
 *						    in one call to receive()
 * 27-09-01 ticp@logica.com added prealocated buffer for socket reads
 *						    with customizable size
 * 28-09-01 ticp@logica.com the io streams buffer size is customizable now
 * 01-10-01 ticp@logica.com traces added
 */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
色综合久久久久| 国产成人精品免费| 亚洲欧洲精品成人久久奇米网| 欧洲视频一区二区| 色女孩综合影院| 色婷婷国产精品综合在线观看| 91网址在线看| 日本道免费精品一区二区三区| 日本精品一区二区三区四区的功能| 成人福利视频网站| 91原创在线视频| 欧美色偷偷大香| 欧美一二三区在线| 91精品麻豆日日躁夜夜躁| 欧美成人三级电影在线| 久久精品一区二区三区不卡牛牛| 久久久亚洲精品石原莉奈| 中文乱码免费一区二区| 自拍视频在线观看一区二区| 一区二区三区四区不卡视频| 水野朝阳av一区二区三区| 三级欧美在线一区| 国产麻豆精品久久一二三| 99re成人精品视频| 欧美三级日韩在线| 欧美电影免费提供在线观看| 久久精品视频一区二区| 亚洲人成网站影音先锋播放| 日韩精品电影在线| 国产精品91一区二区| 色综合天天天天做夜夜夜夜做| 欧美在线观看视频一区二区三区| 日韩一区二区免费视频| 国产欧美精品一区二区三区四区| 亚洲欧美国产77777| 久久国产尿小便嘘嘘| 波多野结衣在线一区| 欧美精品777| 国产精品乱码人人做人人爱| 天堂一区二区在线| www.亚洲色图| 欧美大尺度电影在线| 一二三区精品视频| 国产综合久久久久久久久久久久| 色香蕉久久蜜桃| 欧美精品一区二区在线观看| 一区二区三区.www| 成人精品视频一区二区三区| 91精品综合久久久久久| 亚洲欧美国产高清| 国产一区福利在线| 欧美精品在欧美一区二区少妇| 国产欧美日韩精品a在线观看| 日韩激情中文字幕| 欧美性受xxxx| 最新日韩在线视频| 粉嫩高潮美女一区二区三区| 欧美一级视频精品观看| 亚洲自拍与偷拍| 99精品久久只有精品| 2024国产精品| 久久国产成人午夜av影院| 欧美三级日韩在线| 亚洲人精品午夜| 99久久精品一区二区| 国产日韩影视精品| 久久99精品国产91久久来源| 91精品婷婷国产综合久久性色| 亚洲国产精品人人做人人爽| 成a人片亚洲日本久久| 国产无遮挡一区二区三区毛片日本| 日本网站在线观看一区二区三区| 欧美综合在线视频| 亚洲精品视频免费看| 91在线你懂得| 亚洲色图欧美激情| 91丨九色丨蝌蚪丨老版| 亚洲三级在线免费| 色激情天天射综合网| 亚洲综合久久久| 免费国产亚洲视频| 在线亚洲免费视频| 亚洲人成在线播放网站岛国| 色综合久久中文字幕综合网| 亚洲欧美偷拍卡通变态| 色婷婷亚洲精品| 亚洲123区在线观看| 欧美一级二级三级蜜桃| 精品一区二区三区免费毛片爱| 欧美精品一区二区三区一线天视频| 久久99国产精品免费网站| 久久亚洲二区三区| 成人性生交大合| 亚洲靠逼com| 欧美久久久久中文字幕| 福利一区福利二区| 欧美性高清videossexo| 天天亚洲美女在线视频| 欧美xxxxxxxx| 成人成人成人在线视频| 亚洲人吸女人奶水| 91精品国产黑色紧身裤美女| 久久99精品一区二区三区三区| 欧美国产一区在线| 欧美性感一区二区三区| 国内欧美视频一区二区| 亚洲日本一区二区| 日韩一区二区在线看| 成人高清视频在线| 日韩av成人高清| 成人av网站在线| 日韩主播视频在线| 国产午夜亚洲精品午夜鲁丝片| 色综合久久久网| 亚洲国产成人porn| 久久久久久亚洲综合| 色视频欧美一区二区三区| 国内外精品视频| 亚洲123区在线观看| 国产精品三级av| 日韩欧美中文字幕公布| 91久久精品一区二区三区| 日韩一级成人av| 色综合视频一区二区三区高清| 韩国成人福利片在线播放| 亚洲电影在线播放| 国产精品二区一区二区aⅴ污介绍| 欧美日韩精品欧美日韩精品| www.欧美日韩| 国产成人综合自拍| 免费在线看一区| 亚洲一区在线观看免费观看电影高清 | 日韩一区二区三区三四区视频在线观看| 日韩黄色一级片| 一区二区三区加勒比av| 国产精品视频第一区| 久久人人爽人人爽| 日韩一级完整毛片| 精品视频一区二区三区免费| av一本久道久久综合久久鬼色| 国模少妇一区二区三区| 久久精品国产精品亚洲精品| 亚洲成人资源在线| 亚洲主播在线观看| 亚洲欧美日韩人成在线播放| 中文字幕亚洲成人| 国产精品久久久久久亚洲伦| 国产日韩一级二级三级| 欧美国产亚洲另类动漫| 国产日韩v精品一区二区| 国产偷国产偷亚洲高清人白洁 | 99re视频精品| 99热精品国产| 9色porny自拍视频一区二区| 成人久久视频在线观看| 91在线国内视频| 色综合久久久久综合体| 欧美怡红院视频| 欧美日韩欧美一区二区| 欧美日韩国产精品自在自线| 欧美日韩国产一级| 欧美精品一二三| 欧美一区二区大片| 欧美大片在线观看一区二区| 日韩精品一区二区在线| 国产亚洲精品资源在线26u| 国产欧美中文在线| 亚洲欧洲日韩综合一区二区| 亚洲另类色综合网站| 午夜精品一区二区三区电影天堂 | 奇米影视7777精品一区二区| 男女性色大片免费观看一区二区 | 亚洲人成7777| 婷婷开心激情综合| 蜜臀国产一区二区三区在线播放| 蜜臀av性久久久久蜜臀aⅴ | 欧美人动与zoxxxx乱| 日韩一区二区电影在线| 久久亚洲一级片| 中文字幕在线不卡国产视频| 亚洲一区二区综合| 麻豆成人91精品二区三区| 国产成人av电影在线| 在线免费亚洲电影| 精品国产露脸精彩对白| 亚洲国产精品国自产拍av| 亚洲综合在线五月| 久久不见久久见中文字幕免费| 不卡一区二区在线| 欧美日韩免费一区二区三区视频| 精品国产91乱码一区二区三区| 中文字幕日韩av资源站| 男人操女人的视频在线观看欧美| 成人性色生活片免费看爆迷你毛片| 欧美日韩国产精选| 自拍偷自拍亚洲精品播放| 美女网站视频久久| 欧美中文字幕亚洲一区二区va在线 | 成人免费高清在线观看| 在线不卡中文字幕播放|