您好,登錄后才能下訂單哦!
把內(nèi)容過程中經(jīng)常用的一些內(nèi)容備份一次,下面內(nèi)容是關(guān)于python通過socket獲得點(diǎn)對(duì)點(diǎn)的信息的內(nèi)容。
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()
返回結(jié)果如下:
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)
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。