node2:/root#netstat -nap | grep 12345
tcp 0 0 192.168.137.3:12345 0.0.0.0:* LISTEN 2990/python
node2:/root#
node2:/root/sbin#cat test_connect.py
# coding = utf-8
# -*- coding:utf-8 -*-
import socket
import time
ip_port = ('192.168.137.3',12345)
s1=socket.socket(socket.AF_INET,socket.SOCK_STREAM)#创建套接字
addr=('192.168.137.3',22)
s1.bind(ip_port)
s1.connect(addr)
time.sleep(10000)
node2:/root/sbin#python test_connect.py
Traceback (most recent call last):
File "test_connect.py", line 10, in
s1.bind(ip_port)
File "/usr/local/python27/lib/python2.7/socket.py", line 227, in meth
return getattr(self._sock,name)(*args)
socket.error: [Errno 98] Address already in use