美文网首页
判断合法的端口号

判断合法的端口号

作者: Wang_Yong | 来源:发表于2018-11-05 14:38 被阅读0次

端口号为整数,范围在0~65535之间

function isLegalPort(port){
  if((typeof port !== 'number' && typeof  !== 'string' ) || (typeof port === 'string' && !port.trim().length)) return false
  return +port === (+port >>> 0) && +port <= 0xFFFF
}

相关文章

网友评论

      本文标题:判断合法的端口号

      本文链接:https://www.haomeiwen.com/subject/hodsxqtx.html