SOCKET listen参数

  • Post author:
  • Post category:其他


[oswatch@yyjk ~]$ cat testsocket.py

# coding = utf-8

# -*- coding:utf-8 -*-

import socket

import time

BUFSIZE=1024

ip_port = (‘2.2.2.2’,8081)

s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)#创建套接字

s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

s.bind(ip_port)#绑定地址

s.listen(3)

time.sleep(10000)

[oswatch@yyjk ~]$ netstat -nap | grep 8081

(Not all processes could be identified, non-owned process info

will not be shown, you would have to be root to see it all.)

[oswatch@yyjk ~]$ python testsocket.py

telnet 2.2.2.2 8081

[oswatch@yyjk ~]$ ss -lnt | grep 8081

LISTEN     4      3               2.2.2.2:8081                     *:*

[oswatch@yyjk ~]$ netstat -nap | grep 8081

(Not all processes could be identified, non-owned process info

will not be shown, you would have to be root to see it all.)



版权声明:本文为zhaoyangjian724原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。