天天看點

1套接字IP4和簡單的客戶服務端

#coding=utf-8

import socket

print socket.gethostname() #擷取主機名

print socket.gethostbyname(socket.gethostname()) #擷取IP位址

try:

print socket.gethostbyname('www.163.com') #擷取遠端位址IP

except Exception, e:

raise e

用戶端:one_client.py

服務端:one_server.py

1套接字IP4和簡單的客戶服務端