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

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

?? multicastmaindetectionlistener.java

?? JADE(JAVA Agent開發框架)是一個完全由JAVA語言開發的軟件,它簡化了多Agent系統的實現。
?? JAVA
字號:
package jade.core;import jade.core.MainDetectionManager.MulticastParams;import jade.mtp.TransportAddress;import jade.util.Logger;import jade.util.leap.ArrayList;import jade.util.leap.Iterator;import jade.util.leap.List;import java.io.IOException;import java.net.DatagramPacket;import java.net.InetAddress;import java.net.MulticastSocket;import java.net.UnknownHostException;//#J2ME_EXCLUDE_FILEclass MulticastMainDetectionListener implements Runnable {	private final static Logger logger = Logger.getMyLogger(MulticastMainDetectionListener.class.getName());	private final static int DGRAM_BUF_LEN = 1024;	private ProfileImpl profile;	private IMTPManager manager;	private MulticastParams mcast;	private InetAddress mcastGroupAddress;	private MulticastSocket socket;	private boolean active;		public MulticastMainDetectionListener(ProfileImpl profile, IMTPManager manager) throws ProfileException {		active = false;		this.profile = profile;		this.manager = manager;		mcast = new MainDetectionManager.MulticastParams(profile);		try {			mcastGroupAddress = InetAddress.getByName(mcast.address);		} catch (UnknownHostException e) {			throw new ProfileException("Cannot resolve address "+mcast.address, e);		}		if (!mcastGroupAddress.isMulticastAddress()) {			throw new ProfileException("Address "+mcast.address+" is not a multicast address");		}		try {			socket = new MulticastSocket(mcast.port);				socket.joinGroup(mcastGroupAddress);			socket.setTimeToLive(mcast.ttl);		} catch (IOException ioe) {			throw new ProfileException("Error setting up multicast socket", ioe);		}	}	private String errorResponse(String code, String msg) {		return code+" "+msg;	}	void stop() {		if (active) {			active = false;			if (socket != null) {				try {					socket.leaveGroup(mcastGroupAddress);				} catch (IOException e) {					logger.log(Logger.FINER, "Error leaving multicast group", e);				}				socket.close();			}		}	}	private String serveGetMain(String request) throws IMTPException {		logger.log(Logger.FINER, "MulticastMainDetectionListener::serveGetMain(request=\""+request+"\")");		String response = null;		int i;		String proto = null;		String platformName = null;		// request is in form:		//     get-main[@platform_name][:protocol_name]		// does request contain a desired protocol?		i = request.indexOf(':');		if (i > 0) {			proto = request.substring(i+1);			request = request.substring(0, i);			logger.log(Logger.FINER, "MulticastMainDetectionListener::serveGetMain(): desired proto is \""+proto+"\"");		}		// does request contain a platform name?		i = request.indexOf('@');		if (i > 0) {			platformName = request.substring(i+1);			request = request.substring(0, i);			logger.log(Logger.FINER, "MulticastMainDetectionListener::serveGetMain(): request is for platform \""+platformName+"\"");		}		String myPlatform = profile.getParameter(Profile.PLATFORM_ID, null);		if (platformName != null && !platformName.equals(myPlatform)) {			// not my platform, bail out with no response			logger.log(Logger.FINER, "MulticastMainDetectionListener::serveGetMain(): my platform is \""+myPlatform+"\" while request is for platform \""+platformName+"\" --> Do not reply");			return null;		}		List addresses = manager.getLocalAddresses();		List responseAddresses = new ArrayList(addresses.size());		Iterator iter = addresses.iterator();		TransportAddress addr;		while (iter.hasNext()) {			addr = (TransportAddress)iter.next();			if (proto != null) {				if (proto.equals(addr.getProto())) {					responseAddresses.add(addr);					break;				}			} else {				responseAddresses.add(addr);			}		}		if (responseAddresses.size() < 1) {			response = errorResponse(MainDetectionManager.PROTO_RESP_NOTFOUND, "Cannot manage protocol "+proto);		} else {			response = MainDetectionManager.PROTO_RESP_OK;			iter = responseAddresses.iterator();			while (iter.hasNext()) {				addr = (TransportAddress)iter.next();				// FIXME use toString()				//response += addr.toString();				response += addr.getProto()+MainDetectionManager.PROTO_ADDR_SEPARATOR+addr.getHost()+MainDetectionManager.PROTO_ADDR_SEPARATOR+addr.getPort();				if (iter.hasNext()) {					response += MainDetectionManager.PROTO_ADDRESSES_SEPARATOR;				}			}		}		return response;	}	private String executeRequest(String request) throws Exception {		logger.log(Logger.FINER, "MulticastMainDetectionListener::executeRequest(request=\""+request+"\")");		String result = null;		if (request.indexOf(MainDetectionManager.PROTO_CMD_GETMAIN) == 0) {			// command [get main]			if (profile.isFirstMain()) {				// only master main replies to [get main] commands				result = serveGetMain(request);			} else {				logger.log(Logger.FINER, "MulticastMainDetectionListener::executeRequest(): I'm not master --> Do not reply");			}		} else if (request.indexOf(MainDetectionManager.PROTO_CMD_PING) == 0) {			throw new Exception("Command not implemented yet");		} else {			throw new Exception("Command not implemented");		}		return result;	}	private String manageRequest(byte[] requestBuffer) {		logger.log(Logger.FINER, "MulticastMainDetectionListener::manageRequest(...)");		String result = null;		String request;		request = MainDetectionManager.decodeData(requestBuffer);		if (request == null) {			throw new RuntimeException("Error decoding request");		}		try {			logger.log(Logger.FINER, "MulticastMainDetectionListener::manageRequest(): request.length()="+request.length());			if (request.length() <= MainDetectionManager.PROTO_VERSION.length()) {				throw new Exception("Bad request [request=\""+request+"\"");			}			int i = MainDetectionManager.checkProtocolVersion(request);			request = request.substring(0, i);			result = executeRequest(request);		} catch (Exception e) {			throw new RuntimeException("Error managing request \""+request+"\"", e);		}		return result;	}	public void run() {		logger.log(Logger.FINE, "MulticastMainDetectionListener::run()");		try {			String response;			InetAddress clientAddr;			int responsePort;			active = true;			while (true) {				try {					byte[] buf = new byte[DGRAM_BUF_LEN];					DatagramPacket packet = new DatagramPacket(buf, buf.length);					try {						socket.receive(packet);					} catch (IOException ioe) {						/*						 * when stop() is called, we get here with a						 * SocketException: Socket closed and active == false						 */						if (active) {							/*							 * if active is still true, then something went wrong							 */							logger.log(Logger.SEVERE, "Error in receive()", ioe);						}						// in both cases, it's better to get outta here						break;					}					logger.log(Logger.FINER, "MulticastMainDetectionListener::run(): "+packet.getLength()+" bytes received");					try {						response = manageRequest(packet.getData());					} catch (Exception e) {						logger.log(Logger.WARNING, "MulticastMainDetectionListener::run(): error managing request", e);						response = errorResponse(MainDetectionManager.PROTO_RESP_ERR, e.getMessage());					}					if (response != null) {						response += MainDetectionManager.PROTO_VERSION;						buf = response.getBytes(MainDetectionManager.PROTO_ENCODING);								// get client info						clientAddr = packet.getAddress();						responsePort = packet.getPort();								// prepare packet to be sent back return to client						packet = new DatagramPacket(buf, buf.length, clientAddr, responsePort);						logger.log(Logger.FINER, "MulticastMainDetectionListener::run(): sending response \""+response+"\" to "+clientAddr+":"+responsePort);						socket.send(packet);					} else {						logger.log(Logger.FINE, "MulticastMainDetectionListener::run(): discarded request, sending no response");					}				} catch(IOException ioe) {					logger.log(Logger.WARNING, "Input-output error", ioe);				}			}		} catch (Exception e) {			logger.log(Logger.SEVERE, "Error in listener thread, MulticastMainDetectionListener is no more active", e);		}	}}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
麻豆91免费看| 一区二区三区免费| 日韩二区三区在线观看| 欧美乱熟臀69xxxxxx| 亚洲国产精品久久不卡毛片| 欧美日韩不卡在线| 久久99精品久久只有精品| 日本一区二区三区电影| 95精品视频在线| 亚洲国产精品一区二区www在线| 日韩理论片在线| 7777精品久久久大香线蕉| 处破女av一区二区| 三级欧美韩日大片在线看| 久久亚洲影视婷婷| 欧美探花视频资源| 国产精品资源站在线| 一区二区成人在线视频| 亚洲成av人片www| 中文字幕一区二| 精品免费国产一区二区三区四区| www.欧美日韩国产在线| 久久精品久久99精品久久| 亚洲精品福利视频网站| 中文字幕av一区 二区| 欧美一级片在线| 色婷婷亚洲综合| 国产麻豆视频精品| 国产在线乱码一区二区三区| 婷婷久久综合九色综合绿巨人| 中文字幕中文字幕中文字幕亚洲无线| 欧美成人vps| 亚洲视频在线观看一区| 久久er99精品| 91久久精品一区二区| 成人一区二区三区视频在线观看| 91影视在线播放| 国产 日韩 欧美大片| 国产精品综合一区二区三区| 91久久精品一区二区三区| 精品国产三级电影在线观看| 欧美一区二区在线视频| 国产免费久久精品| 秋霞影院一区二区| 日本免费新一区视频| 99re8在线精品视频免费播放| 欧美精品日韩精品| 亚洲精品中文字幕乱码三区| 久久99蜜桃精品| 欧美精品一卡两卡| 国产精品久久久久久久久免费相片 | 91麻豆精品国产自产在线| 国产精品人妖ts系列视频| 久久品道一品道久久精品| 精品电影一区二区三区| 亚洲日本电影在线| 国产99一区视频免费| 日韩精品综合一本久道在线视频| 欧美α欧美αv大片| 亚洲www啪成人一区二区麻豆| 99精品久久久久久| 国产清纯在线一区二区www| 性感美女极品91精品| 在线精品观看国产| 精品精品国产高清a毛片牛牛 | 日韩一区二区免费在线观看| 日韩欧美美女一区二区三区| 亚洲一区二区欧美| 日韩电影在线看| 91久久精品国产91性色tv| 中文字幕亚洲一区二区av在线| 国产精品一二二区| 国产欧美日韩激情| 成人午夜av在线| 国产精品久久久久毛片软件| 丁香激情综合国产| 最新成人av在线| 日本电影欧美片| 亚洲成人午夜影院| 欧美一区二区三区在线观看视频| 五月婷婷久久综合| 91精品国产色综合久久不卡电影 | 不卡的看片网站| 在线成人av影院| 日本不卡中文字幕| www激情久久| www.在线欧美| 午夜不卡av在线| 亚洲精品在线一区二区| 福利一区在线观看| 夜色激情一区二区| 91精品国产综合久久福利| 热久久国产精品| 欧美激情一区二区三区四区| 色综合天天性综合| 精品免费国产一区二区三区四区| 国内精品在线播放| 中文字幕在线不卡一区二区三区| 在线日韩国产精品| 裸体健美xxxx欧美裸体表演| 国产清纯美女被跳蛋高潮一区二区久久w | 国产清纯在线一区二区www| 91丨porny丨户外露出| 亚洲主播在线播放| 久久亚洲一级片| 91丨国产丨九色丨pron| 久久精品国产网站| 国产精品午夜免费| 日韩三级中文字幕| 白白色 亚洲乱淫| 美女久久久精品| 中文字幕在线不卡一区 | 国产日产精品1区| 欧美色图天堂网| 欧美一区二区人人喊爽| 成人一区二区三区视频| 美女在线观看视频一区二区| 亚洲欧美经典视频| 91丨porny丨首页| jvid福利写真一区二区三区| 天堂成人国产精品一区| 亚洲婷婷综合色高清在线| 久久综合精品国产一区二区三区 | 成人久久18免费网站麻豆| 午夜精品成人在线视频| 久久精品一区二区| 国产丶欧美丶日本不卡视频| 国产色一区二区| 在线播放中文一区| 欧美调教femdomvk| 99精品久久久久久| 成人午夜又粗又硬又大| 激情文学综合丁香| 日本 国产 欧美色综合| 天天影视涩香欲综合网| 亚洲精品自拍动漫在线| 日韩理论电影院| **欧美大码日韩| 国产精品乱码人人做人人爱 | 欧洲在线/亚洲| av色综合久久天堂av综合| 国产成人精品在线看| 久久99精品久久久久久国产越南| 婷婷开心久久网| 日本欧美一区二区三区乱码| 午夜精品视频一区| 视频一区二区三区入口| 午夜久久久久久久久| 亚洲一区二区四区蜜桃| 性做久久久久久久久| 五月婷婷综合激情| 老汉av免费一区二区三区| 欧美aaa在线| 另类专区欧美蜜桃臀第一页| 美国一区二区三区在线播放| 极品瑜伽女神91| 国产精品伊人色| 99久久亚洲一区二区三区青草| 成人h动漫精品| 不卡电影免费在线播放一区| eeuss影院一区二区三区| 91视频在线观看| 欧美日韩国产影片| 日韩一区二区三区免费观看| 2024国产精品| 国产精品日韩成人| 亚洲在线视频一区| 美女性感视频久久| 成人国产精品免费观看动漫| 色综合天天做天天爱| 欧美在线免费播放| 欧美电影免费观看完整版| 国产亚洲女人久久久久毛片| 亚洲欧洲99久久| 日韩精品一卡二卡三卡四卡无卡| 久久精工是国产品牌吗| 成人黄色电影在线| 777午夜精品免费视频| 国产欧美日韩久久| 亚洲午夜一区二区| 国产一区三区三区| 欧美主播一区二区三区| 精品免费一区二区三区| 亚洲猫色日本管| 蜜臀av一区二区| 97超碰欧美中文字幕| 欧美一区二区福利在线| 国产精品久久久久影院色老大| 天天综合网 天天综合色| 高清久久久久久| 欧美一区二区三区电影| 成人免费在线视频观看| 蜜桃视频在线观看一区二区| 91免费观看国产| 久久久久国产精品麻豆ai换脸| 樱桃国产成人精品视频| 成人免费精品视频| 亚洲精品在线一区二区| 午夜免费久久看| 欧美亚洲动漫另类|