SOCKET listen参数

SOCKET listen参数,第1张

[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.)

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/738379.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-28
下一篇 2022-04-28

发表评论

登录后才能评论

评论列表(0条)

保存