728x90
반응형
서버
import socket import os server_socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) socket_path = '/tmp/wowcat' # 같은 이름의 파일이 존재할 경우 제거 try: os.unlink(socket_path) except OSError: pass server_socket.bind(socket_path) server_socket.listen() print(f"대기 중: {socket_path}") while True: client_socket, addr = server_socket.accept() print(f"연결 됨: {addr}") # 통신 코드 구현 client_socket.close()
클라이언트
import socket client_socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) # 파일 소켓 경로 socket_path = '/tmp/wowcat' client_socket.connect(socket_path) # 통신 코드 작성 client_socket.close()

728x90
'기술자료 > 파이썬' 카테고리의 다른 글
selectors 초간단 소스 Python (0) | 2023.12.13 |
---|---|
파이썬 Python 창 띄우기 by pygame (0) | 2021.02.10 |