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

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

?? restopeer.java

?? p2p 源代碼
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
import java.io.*;import java.util.*;import java.net.URL;import net.jxta.peergroup.PeerGroup;import net.jxta.peergroup.PeerGroupFactory;import net.jxta.exception.PeerGroupException;import net.jxta.document.AdvertisementFactory;import net.jxta.document.StructuredDocumentFactory;import net.jxta.document.Advertisement;import net.jxta.document.Element;import net.jxta.document.MimeMediaType;import net.jxta.document.StructuredDocument;import net.jxta.document.StructuredTextDocument;import net.jxta.discovery.DiscoveryService;import net.jxta.pipe.PipeService;import net.jxta.pipe.InputPipe;import net.jxta.pipe.OutputPipe;import net.jxta.pipe.PipeID;import net.jxta.protocol.PipeAdvertisement;import net.jxta.protocol.PeerGroupAdvertisement;import net.jxta.protocol.ModuleImplAdvertisement;import net.jxta.endpoint.Message;import net.jxta.id.IDFactory;import net.jxta.peergroup.PeerGroupID;import net.jxta.membership.MembershipService;import net.jxta.membership.Authenticator;import net.jxta.credential.AuthenticationCredential;import net.jxta.impl.peergroup.StdPeerGroupParamAdv;import net.jxta.impl.id.UUID.ModuleClassID;import net.jxta.impl.membership.PasswdMembershipService;// RestoPeer represents a restaurant that receives auction requests// for french fries from HungryPeers. RestoPeers offers three sizes of// french fries (small, large, medium). Each restaurant assignes a// different price to each size. Each restaurant also offers a special// offering.//// Each restaurant is uniquely identified by its brand name.public class RestoPeer {    private PeerGroup netpg = null;      // The NetPeerGroup    private PeerGroup restoNet = null;   // The restoNet Peergroup    private String brand = "Chez JXTA";        // Brand of this restaurant    private String specials = "large ($3.00)"; // Current restaurant special    // Services within the RestoNet peergroup    private DiscoveryService disco = null;  // Discovery service    private PipeService pipes = null;       // Pipe service    private PipeAdvertisement myAdv = null; // My RestoPeer pipe advertisement    private InputPipe pipeIn = null;        // Input pipe that we listen to                                            // for requests from Hungry Peers    private int timeout = 3000;          // discovery wait timeout    private int rtimeout = 8000;         // resolver pipe timeout    private ModuleClassID membershipClassID;    private static PeerGroupID restoPeerGroupID;    static {        try {            restoPeerGroupID =            (PeerGroupID) IDFactory.fromURL(new URL(                  "urn", "", "jxta:uuid-058C59E291174BEFB804AACB9C6A3B5002"));        } catch (Exception e) {            throw new RuntimeException("Can't load RestoPeer");        }    }    public static void main(String args[]) {        RestoPeer myapp = new RestoPeer();        myapp.startJxta();        System.exit(0);    }    // Method to start the JXTA platform, join the RestoNet peergroup and    // advertise the RestoPeer service    private void startJxta() {        try {            //Discover and join (or start) the default peergroup            netpg = PeerGroupFactory.newNetPeerGroup();        } catch (PeerGroupException e) {            //Couldn't initialize; can't continue            System.out.println("Fatal error : creating the NetPeerGroup");            System.exit(1);        }        // Discover (or create) and join the RestoNet peergroup        try {            joinRestoNet();        } catch (Exception e) {            System.out.println("Can't join or create RestoNet");            System.exit(1);        }        // Discover (or create) and publish a RestoPeer pipe to receive        // auction request for fries from HungryPeers        if (!createRestoPipe()) {            System.out.println("Aborting due to failure to create RestoPeer pipe");            System.exit(1);        }        // Start the RestoPeer server loop to respond to Hungry peers        // fries requests.        handleFriesRequest();    }    // Discover (or create) and join the RestoNet peergroup    private void joinRestoNet() throws Exception {        int count = 3;   // maximun number of attempts to discover        System.out.println("Attempting to Discover the RestoNet PeerGroup");        // Get the discovery service from the NetPeergroup        DiscoveryService hdisco = netpg.getDiscoveryService();        Enumeration ae = null;   // Holds the discovered peers        // Loop until wediscover the RestoNet or        // until we've exhausted the desired number of attempts        while (count-- > 0) {            try {                // search first in the peer local cache to find                // the RestoNet peergroup advertisement                ae = hdisco.getLocalAdvertisements(DiscoveryService.GROUP,                                          "Name", "RestoNetAuth");                // If we found the RestoNet advertisement we are done                if ((ae != null) && ae.hasMoreElements())                    break;                // If we did not find it, we send a discovery request                hdisco.getRemoteAdvertisements(null,                       DiscoveryService.GROUP, "Name", "RestoNetAuth", 1, null);                // Sleep to allow time for peers to respond to the                // discovery request                try {                    Thread.sleep(timeout);                } catch (InterruptedException ie) {}            } catch (IOException e){                // Found nothing! Move on            }        }        PeerGroupAdvertisement restoNetAdv = null;        // Check if we found the RestoNet advertisement.        // If we didn't, then either        //       we are the first peer to join or        //       no other RestoNet peers are up.        // In either case, we must create the RestoNet peergroup        if (ae == null || !ae.hasMoreElements()) {            System.out.println(                 "Could not find the RestoNet peergroup; creating one");            try {                // Create a new, all-purpose peergroup. Because we                // have a custom peergroup advertisement, we must                // create the module impl advertisement and then                // the peergroup advertisement (just as we did when                // we created the peergroup as a service).                ModuleImplAdvertisement implAdv =                    createAuthPeerGroupModuleImplAdv(netpg);                hdisco.publish(implAdv, DiscoveryService.ADV,                        PeerGroup.DEFAULT_LIFETIME,                        PeerGroup.DEFAULT_EXPIRATION);                hdisco.remotePublish(implAdv, DiscoveryService.ADV,                        PeerGroup.DEFAULT_EXPIRATION);                restoNetAdv =                    createPeerGroupAdvertisement(implAdv, "RestoNetAuth");                // The peergroup advertisement membership service needs                // to have a parameter that initializes the valid                // users and passwords. Create a document that holds that                // information. There can be any number of login:passwd:                // pairs in the login tag value.                StructuredTextDocument pwds = (StructuredTextDocument)                    StructuredDocumentFactory.newStructuredDocument(                    new MimeMediaType("text/xml"), "Parm");                Element e = pwds.createElement("login",                    "hungrypeer:" +                    PasswdMembershipService.makePsswd("password") + ":");                pwds.appendChild(e);                restoNetAdv.putServiceParam(membershipClassID, pwds);                // Now publish the modified advertisement as usual                hdisco.publish(restoNetAdv, DiscoveryService.GROUP,                        PeerGroup.DEFAULT_LIFETIME,                        PeerGroup.DEFAULT_EXPIRATION);                hdisco.remotePublish(restoNetAdv, DiscoveryService.GROUP,                        PeerGroup.DEFAULT_EXPIRATION);                restoNet = netpg.newGroup(restoNetAdv);            } catch (Exception e) {                System.out.println("Error in creating RestoNet Peergroup " + e);                throw e;            }        } else {            // The RestoNet advertisement was found in the cache;            // that means we can join the existing RestoNet peergroup            try {                restoNetAdv = (PeerGroupAdvertisement) ae.nextElement();                restoNet = netpg.newGroup(restoNetAdv);                System.out.println(                    "Found the RestoNet Peergroup advertisement");            } catch (Exception e) {                System.out.println("Error in creating RestoNet PeerGroup from existing adv");                throw e;            }        }        // Instead of just joining, we must authenticate too        authenticateAndJoin(restoNet);        try {            // Get the discovery and pipe services for the RestoNet Peergroup            disco = restoNet.getDiscoveryService();            pipes = restoNet.getPipeService();        } catch (Exception e) {            System.out.println("Error getting services from RestoNet");            throw e;        }        System.out.println("RestoNet Restaurant (" + brand + ") is on-line");        return;    }    // Method to handle fries auction requests from HungryPeers.    // The method waits for HungryPeer requests pipe messages to arrive.    // Incoming requests contain a pipe advertisement to respond to    // the HungryPeers requester and a fries size.  The method    // generates a bid offer for the request, opens an output pipe to    // the HungryPeer requester, and send the response.    private void handleFriesRequest() {        InputStream ip = null;               // Input Stream to read message        PipeAdvertisement hungryPipe = null; // HungryPeer Requester pipe        StructuredDocument request = null;   // Request document        StructuredDocument bid = null;       // Response document        // Document mime types        MimeMediaType mimeType = new MimeMediaType("text", "xml");        Element el = null;                   // Element in document        String name = null;                  // Name of the sender        String size = null;                  // Fries size Requested        OutputPipe pipeOut = null;           // Output pipe to respond to                                             // HungryPeer requester        System.out.println("RestoNet Restaurant (" + brand +                           ") waiting for HungryPeer requests");        // Loop waiting for HungryPeer Requests        while (true) {            Message msg = null;          // Incoming pipe message            try {                // Block until a message arrive on the RestoPeer pipe                msg = pipeIn.waitForMessage();                // If message is null discard message                if (msg == null) {                   if (Thread.interrupted()) {                        // We have been asked to stop                        System.out.println("Abort: RestoPeer interrupted");                        return;                    }                }                // We received a message; extract the request                try {                    // Extract the HungryPipe pipe information                    // to reply to the sender                    ip = msg.getElement("HungryPeerPipe").getStream();                    // Construct the associated pipe advertisement                    // via the AdvertisementFactory                    hungryPipe = (PipeAdvertisement)                    AdvertisementFactory.newAdvertisement(mimeType, ip);                    // Extract the sender name and fries size requested                    // building a StructuredDocument                    ip = msg.getElement("Request").getStream();                    request = StructuredDocumentFactory.newStructuredDocument                                    (mimeType, ip);                    // Extract the fields from the structured Document                    Enumeration enum = request.getChildren();                    // Loop over all the elements of the document                    while (enum.hasMoreElements()) {                        el = (Element) enum.nextElement();                        String attr = (String) el.getKey();                        String value = (String) el.getValue();                        // Extract the HungryPeer Requester Name                        if (attr.equals("Name")) {                            name = value;                            continue;                        }                        // Extract the Fries  size requested                        else if (attr.equals("Fries")) {                            size = value;                            continue;                        }                    }                } catch (Exception e) {                    continue; // Broken content; silently discard                }                System.out.println("Received Request from HungryPeer "                               + name                               + " for "                               + size                               + " Fries.");                // The auction request is valid. We can

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日本在线一区| 欧美成人乱码一区二区三区| 欧美浪妇xxxx高跟鞋交| 欧美精品一区视频| 久久久久久久国产精品影院| 国产欧美一区二区精品性| 欧美国产精品一区二区三区| 一区二区三区四区蜜桃| 久久福利资源站| 色婷婷综合久久久| 欧美情侣在线播放| 久久精品日产第一区二区三区高清版 | 国产精品国产三级国产aⅴ入口| 亚洲国产美女搞黄色| 国产一区二区精品在线观看| 色老汉av一区二区三区| 国产亚洲一二三区| 青娱乐精品在线视频| 91免费版pro下载短视频| 制服丝袜亚洲精品中文字幕| 国产精品美女久久久久久| 蜜桃久久久久久| 久久精品国产99久久6| 99久久精品费精品国产一区二区| 日韩欧美aaaaaa| 亚洲高清视频在线| 91丨九色porny丨蝌蚪| 久久久久久久性| 美腿丝袜在线亚洲一区| 欧美色精品在线视频| 亚洲三级在线观看| 成人性生交大片| 久久免费看少妇高潮| 裸体在线国模精品偷拍| 欧美猛男男办公室激情| 自拍偷拍亚洲激情| av午夜精品一区二区三区| 欧美精品一区二区高清在线观看| 日本欧美在线观看| 91精品国产手机| 肉丝袜脚交视频一区二区| 色欧美88888久久久久久影院| 国产精品久久久久久久久免费相片 | 国产欧美精品一区二区色综合 | 韩国v欧美v亚洲v日本v| 精品国产免费视频| 九一久久久久久| 欧美大肚乱孕交hd孕妇| 久久精品国产色蜜蜜麻豆| 欧美一区日韩一区| 玖玖九九国产精品| 欧美一级理论片| 裸体在线国模精品偷拍| 精品日韩99亚洲| 久久99久久久久久久久久久| 精品国产乱码久久久久久老虎| 久久不见久久见免费视频7| 欧美日韩国产一二三| 夜夜嗨av一区二区三区中文字幕| 色综合久久中文综合久久牛| 亚洲高清免费视频| 91精品国产色综合久久不卡电影 | 日韩欧美精品在线视频| 久久精品99国产精品| 2017欧美狠狠色| www.激情成人| 亚洲第一狼人社区| 欧美一区二区观看视频| 国产一区二区三区四| 久久久久久久久蜜桃| 不卡的av在线| 午夜精品久久久久久久99水蜜桃| 欧美一区二区三区在线视频| 国产精品自拍一区| 亚洲丝袜制服诱惑| 欧美久久久久久久久中文字幕| 毛片av中文字幕一区二区| 久久影院视频免费| 国产盗摄精品一区二区三区在线| 国产精品久久久久久久久免费樱桃 | 国产日韩视频一区二区三区| 波多野结衣在线aⅴ中文字幕不卡| 一区二区三区四区av| 精品国产制服丝袜高跟| 粉嫩绯色av一区二区在线观看| 亚洲国产综合色| 久久久久久久久久美女| 欧洲av在线精品| 国产曰批免费观看久久久| 亚洲激情六月丁香| 久久综合丝袜日本网| 91在线观看污| 狠狠色丁香九九婷婷综合五月| 专区另类欧美日韩| 亚洲精品在线一区二区| 在线国产亚洲欧美| 岛国一区二区三区| 日本aⅴ亚洲精品中文乱码| 欧美激情艳妇裸体舞| 欧美日韩高清影院| 99久久久久免费精品国产| 美女久久久精品| 亚洲欧美日本韩国| 国产欧美日本一区二区三区| 欧美一区二区在线不卡| 欧美性猛交xxxxxxxx| 成人不卡免费av| 国产中文一区二区三区| 日韩精品成人一区二区三区| 亚洲免费电影在线| 国产精品久久久久久户外露出| 日韩丝袜情趣美女图片| 在线观看日韩电影| 99久免费精品视频在线观看| 国产一区二三区| 美女脱光内衣内裤视频久久网站 | 精品黑人一区二区三区久久 | 日韩av一区二区在线影视| 亚洲免费av高清| 亚洲欧美综合另类在线卡通| 国产亚洲精品精华液| 精品国产亚洲一区二区三区在线观看| 91精品国产高清一区二区三区| 欧美在线观看视频一区二区| 91丨porny丨国产| 成人av午夜影院| 国产成人av影院| 国产高清视频一区| 国产精品一级在线| 国产jizzjizz一区二区| 国产精品夜夜嗨| 粉嫩一区二区三区性色av| 黄色资源网久久资源365| 精品一区二区在线播放| 国产伦精品一区二区三区免费 | 精品国产乱码久久久久久久| 精品国产百合女同互慰| 久久久久久电影| 亚洲国产精品激情在线观看| 国产精品久久久久国产精品日日 | 欧美变态凌虐bdsm| 精品国产一区久久| 国产日韩欧美a| 亚洲天堂2014| 午夜精品爽啪视频| 美女视频一区二区| 国产精品一区2区| 91在线视频在线| 欧美久久一二三四区| 欧美大片国产精品| 欧美激情一区在线观看| 国产日产亚洲精品系列| 国产欧美一区二区精品久导航 | 99re成人精品视频| 天堂一区二区在线免费观看| 国内精品视频一区二区三区八戒 | 一色屋精品亚洲香蕉网站| 亚洲成人免费电影| 国产91精品入口| 在线不卡免费av| 亚洲色图欧美偷拍| 精品一区二区三区视频在线观看| 色综合一个色综合| 精品盗摄一区二区三区| 亚洲精品日韩专区silk| 国产精品66部| 日韩一级免费观看| 亚洲一区二区三区精品在线| 国产传媒一区在线| 91精品婷婷国产综合久久性色| 亚洲天堂a在线| 国产91在线观看| 精品福利一区二区三区免费视频| 亚洲一区av在线| 972aa.com艺术欧美| 国产片一区二区三区| 毛片一区二区三区| 91精品国产综合久久精品| 亚洲影视在线观看| 成人免费观看av| 久久久久综合网| 美女视频一区二区| 欧美一级片免费看| 午夜精彩视频在线观看不卡| 欧洲精品在线观看| 亚洲精品一二三区| 97精品电影院| |精品福利一区二区三区| 国产成人精品亚洲日本在线桃色| 精品处破学生在线二十三| 美脚の诱脚舐め脚责91 | 18成人在线观看| 成人av电影在线播放| 国产精品乱码一区二区三区软件 | 国产清纯白嫩初高生在线观看91| 国产一区二区三区免费在线观看| 精品黑人一区二区三区久久| 国产综合成人久久大片91| 久久综合九色综合欧美98| 激情综合网激情|