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