国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

通過零拷貝實現有效數據傳輸

2019-11-17 04:17:42
字體:
來源:轉載
供稿:網友

源:http://www.ibm.com/developerworks/cn/java/j-zerocopy/index.html

主要看代碼就可以了.

view plaincopy to clipboardPRint?
public void testSendfile() throws IOException {  
        String host = "localhost";  
        int port = 9026;  
        SocketAddress sad = new InetSocketAddress(host, port);  
        SocketChannel sc = SocketChannel.open();  
        sc.connect(sad);  
        sc.configureBlocking(true);  
 
        String fname = "sendfile/NetworkInterfaces.c";  
        long fsize = 183678375L, sendzise = 4094;  
          
        // FileProposerExample.stuffFile(fname, fsize);  
        FileChannel fc = new FileInputStream(fname).getChannel();  
            long start = System.currentTimeMillis();  
        long nsent = 0, curnset = 0;  
        curnset =  fc.transferTo(0, fsize, sc);  
        System.out.println("total bytes transferred--"+curnset+" and time taken in MS--"+(System.currentTimeMillis() - start));  
        //fc.close();  
      } 
public void testSendfile() throws IOException {
     String host = "localhost";
     int port = 9026;
     SocketAddress sad = new InetSocketAddress(host, port);
     SocketChannel sc = SocketChannel.open();
     sc.connect(sad);
     sc.configureBlocking(true);

     String fname = "sendfile/NetworkInterfaces.c";
     long fsize = 183678375L, sendzise = 4094;
    
     // FileProposerExample.stuffFile(fname, fsize);
     FileChannel fc = new FileInputStream(fname).getChannel();
            long start = System.currentTimeMillis();
     long nsent = 0, curnset = 0;
     curnset =  fc.transferTo(0, fsize, sc);
     System.out.println("total bytes transferred--"+curnset+" and time taken in MS--"+(System.currentTimeMillis() - start));
     //fc.close();
   }


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 察隅县| 仲巴县| 娱乐| 西吉县| 德兴市| 武功县| 星子县| 柯坪县| 凌源市| 屏东市| 石狮市| 连江县| 长治市| 鄢陵县| 高雄县| 乐都县| 昆山市| 板桥市| 永州市| 德清县| 勐海县| 濮阳市| 时尚| 平定县| 运城市| 蓬溪县| 崇文区| 永城市| 威远县| 确山县| 祁阳县| 鱼台县| 筠连县| 大同县| 钟山县| 莲花县| 南雄市| 司法| 东乌珠穆沁旗| 岳阳县| 屯昌县|