Created
November 21, 2018 12:29
-
-
Save zerobell-lee/72a05ac4a1b836f845dbc9ede321ddb2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from socket import * | |
def send(sock): | |
sendData = input('>>>') | |
sock.send(sendData.encode('utf-8')) | |
def receive(sock): | |
recvData = sock.recv(1024) | |
print('상대방 :', recvData.decode('utf-8')) | |
port = 8080 | |
serverSock = socket(AF_INET, SOCK_STREAM) | |
serverSock.bind(('', port)) | |
serverSock.listen(1) | |
print('%d번 포트로 접속 대기중...'%port) | |
connectionSock, addr = serverSock.accept() | |
print(str(addr), '에서 접속되었습니다.') | |
while True: | |
send(connectionSock) | |
receive(connectionSock) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment