⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ipmaddress.java

📁 飞鸽java源代码
💻 JAVA
字号:
/*
 * IP Messenger Address Class
 * 1998/01/26 (C)Copyright T.Kazawa(Digitune)
 */

package ipmsg;

import java.net.InetAddress;

public class IPMAddress {
	int port;
	InetAddress addr;
	
	public IPMAddress(int argport, InetAddress argaddr) {
		port = argport;
		addr = argaddr;
	}
	
	public IPMAddress(byte[] argbuf) {
		int sep = 0;
		while (argbuf[sep] != ":".getBytes()[0] && sep < argbuf.length - 1)
			sep++;
		byte[] ipbuf = new byte[sep];
		byte[] portbuf = new byte[argbuf.length - sep - 1];
		System.arraycopy(argbuf, 0, ipbuf, 0, sep);
		System.arraycopy(argbuf, sep + 1, portbuf, 0, argbuf.length - sep - 1);
		try {
			addr = InetAddress.getByName(new String(ipbuf));
		} catch (Exception ex) {
			ex.printStackTrace();
			addr = null;
		}
		try {
			port = Integer.valueOf(new String(portbuf)).intValue();
		} catch (Exception ex) {
			ex.printStackTrace();
			port = 0;
		}
	}
	
	public int getPort() {
		return port;
	}
	
	public InetAddress getInetAddress() {
		return addr;
	}
	
	public String toString() {
		return addr.getHostAddress() + ":" + port;
	}
}

⌨️ 快捷键说明

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