您好,登錄后才能下訂單哦!
把內容過程中經常用的一些內容備份一次,下面內容是關于python通過socket獲得點對點的信息的內容。
import socket
print "Creating socket...",
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print "done."
print "Looking up port number...",
port = socket.getservbyname('http', 'tcp')
print "done."
print "Connecting to remote host on port %d..." % port,
print "done."
print "Connected from", s.getsockname()
print "Connected to", s.getpeername()
返回結果如下:
Creating socket... done.
Looking up port number... done.
Connecting to remote host on port 80... done.
Connected from ('127.0.0.1', 51475)
Connected to ('116.255.236.107', 80)
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。