python Network

언어/python2016. 3. 24. 22:11

아직 네트워크에 대해 잘 모르기 때문에 나중을 위해서 기록

server

import socket

s= socket.socket()
host = socket.gethostname()
port = 12345
s.bind((host, port))

s.listen(5)

while True:
c, addr = s.accept()
print ("Got connection", addr)
c.send("Thank you for connecting".encode())
c.close()


client

import socket

s = socket.socket()
host = socket.gethostname()
port = 12345

s.connect((host,port))
print(s.recv(1234))
s.close


'언어 > python' 카테고리의 다른 글

class  (0) 2016.05.16
정밀한 값이 아니다 파이썬 행렬  (0) 2016.04.04
python 문자열  (0) 2016.03.13
python exception handling  (0) 2016.03.12
암호 ver4.1  (0) 2016.02.16