더북(TheBook)

이 과정을 수행하려면 send(message, destination)receive() 이렇게 두 행위가 필요하다. 이 과정은 한 컴퓨터 안의 두 스레드뿐만 아니라 네트워크상에 있는 두 컴퓨터 사이에서도 가능하다.

 

이를 코드로 옮기면 다음과 같다.

# Chapter 5/sockets.py
import socket
import os.path
import time
from threading import Thread, current_thread

SOCK_FILE = "./mailbox" ----- ➊

신간 소식 구독하기
뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.