// Accept the connection and make it non-blocking
SocketChannel socketChannel = serverSocketChannel.accept();
Socket socket = socketChannel.socket();
//socket.setSoTimeout(1000*10);//it will be timeout if idle more than 10s
//after testing, i found the parameter in socketchannel didnot work
//the following is what i google:
//you don't need a timeout,
//because SC's (SC means SocketChannel) do a non-blocking Connect, and send a message to the Selector with message type CONNECTED when that becomes the case

//in the protosocket, read method is a blocking invocation, so it need a "timeout" parameter ,in case some evil connection

parameter "timeout" in socketchannel does not work的更多相关文章

  1. JUnit4:Test注解的两个属性:expected和timeout

    JUnit4:Test文档中的解释: The Test annotation supports two optional parameters. The first, expected, declar ...

  2. Test注解的两个属性:expected和timeout

    JUnit4:Test文档中的解释: The Test annotation supports two optional parameters. The first, expected, declar ...

  3. ajax 请求 对json传的处理 Jquery 使用Ajax获取后台返回的Json数据后,页面处理

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  4. JUnit4注解基本介绍

    @After If you allocate external resources in a Before method you need to release them after the test ...

  5. net programming guid

    Beej's Guide to Network Programming Using Internet Sockets Brian "Beej Jorgensen" Hallbeej ...

  6. Jquery 使用Ajax获取后台返回的Json数据后,页面处理

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  7. Jenkins持续集成学习-Windows环境进行.Net开发2

    目录 Jenkins持续集成学习-Windows环境进行.Net开发2 目录 前言 目标 使用 .Net Stardard 单元测试 流程 手动执行单元测试 自动执行单元测试 单元测试报告 上传Nug ...

  8. Java NIO通信的基础,基于TCP C/S例子介绍

    为了更好的理解Netty异步事件驱动网络通信框架,有必要先了解一点Java NIO原生的通信理论,下面将结合基于TCP的例子程序,含客户端和服务端的源码,实现了Echo流程. Java NIO的核心概 ...

  9. MQTT协议笔记之mqtt.io项目HTTP协议支持

    前言 MQTT协议诞生之初,就未曾考虑通过HTTP传输.这也正常,网络受限.不稳定网络不太适合HTTP(2G/3G网络大家使用WAP不也OK嘛).在网络较为充裕的桌面端而言,虽纯文本对比二进制而言没多 ...

随机推荐

  1. CCMotionStreak(一)

    void MotionStreakTest1::onEnter() { MotionStreakTest::onEnter(); CCSize s = CCDirector::sharedDirect ...

  2. javascript 图片上传缩略图预览

    <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="C ...

  3. 手动方式SQL注入脚本命令之精华版

    .判断是否有注入;and = ;and = .初步判断是否是mssql ;and user> .注入参数是字符and [查询条件] and = .搜索时没过滤参数的and [查询条件] and ...

  4. js实现点击按钮实现上一张下一张相册滚动效果

    /****判断图片是否构成滚动效果*/$(function(){    if($("#bar").find('img').size()*71<=$("#bar&qu ...

  5. eclipse 启动报share library load faild

      eclipse 与 jdk 版本要一致 *32 - 对应32位 *64 - 对应64位

  6. javascript 中XMLHttpRequest 实现前台向后台的交互

    使用XMLHttpRequest对象分为4部完成: 1.创建XMLHttpRequest组建 2.设置回调函数 3.初始化XMLHttpRequest组建 4.发送请求

  7. How to Use HTML5 FUll Screen API(如何使用HTML5全屏接口) 【精】

    原文链接:http://www.sitepoint.com/use-html5-full-screen-api/ 如果你不太喜欢变化太快的东西,那么web开发可能不适合你.我曾在2012年末有写过Fu ...

  8. android开发中用到的px、dp、sp

    先介绍一下这几个单位: px : pixels(像素),相应屏幕上的实际像素点. dip :device independent pixels,与密度无关的像素,基于屏幕密度的抽象单位. 在每英寸16 ...

  9. 为gridview的每个单元格添加鼠标悬停提示文本(tooltip)

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)    {        for (int i ...

  10. zookeeper连接 org.apache.curator.framework.imps.CuratorFrameworkImpl Background exception was not retry-able or retry gave up [main-EventThread]

    ERROR org.apache.curator.framework.imps.CuratorFrameworkImpl Background exception was not retry-able ...