Skip to content

Instantly share code, notes, and snippets.

@zerobell-lee
Created November 21, 2018 13:14
Show Gist options
  • Save zerobell-lee/49a7a7e68af70f59a1783fcf508c1f70 to your computer and use it in GitHub Desktop.
Save zerobell-lee/49a7a7e68af70f59a1783fcf508c1f70 to your computer and use it in GitHub Desktop.
from socket import *
import threading
import time
def send(sock):
while True:
sendData = input('>>>')
sock.send(sendData.encode('utf-8'))
def receive(sock):
while True:
recvData = sock.recv(1024)
print('상대방 :', recvData.decode('utf-8'))
port = 8081
clientSock = socket(AF_INET, SOCK_STREAM)
clientSock.connect(('127.0.0.1', port))
print('접속 완료')
sender = threading.Thread(target=send, args=(clientSock,))
receiver = threading.Thread(target=receive, args=(clientSock,))
sender.start()
receiver.start()
while True:
time.sleep(1)
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment