| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 |
Tags
- collections.deque
- 수 정렬하기
- Numpy
- Sequential Search
- centuryFromYear
- Counting cells in a blob
- Daily Commit
- almostIncreasingSequence
- shapeArea
- flask
- codesingal
- baekjun
- C++
- 10953
- 피보나치 수
- cpp
- codesignal
- 파이썬머신러닝완벽가이드
- 2750
- til
- matrixElementsSum
- Python
- 백준
- adjacentElementsProduct
- data_structure
- markdown
- All Longest Strings
- recursion
- 파이썬 포렌식
- 2015 봄학기 알고리즘
Archives
- Today
- Total
Introfor
Socket_Chatting 본문
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | __author__="Introfor" # -*-coding: utf-8 -*- # server.py import socket import thread HOST = 'localhost' PORT = 50000 s = socket.socket() s.bind((HOST, PORT)) s.listen(1) conn, addr = s.accept() print 'Connected by', addr data = '' def msg(): while 1: data = conn.recv(1024) if data: print data.lower() thread.start_new_thread(msg, ()) while 1: send_data = raw_input() if send_data[:4] in ['quit', 'Quit', 'QUIT']: conn.send('Server Quit') thread.exit() conn.close() conn.send('Server : ' + send_data) | cs |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | __author__="Introfor" # -*-coding: utf-8 -*- # client.py import socket import thread HOST = 'localhost' PORT = 50000 s = socket.socket() s.connect((HOST, PORT)) data = '' def msg(): while 1: data = s.recv(1024) if data: print data.lower() thread.start_new_thread(msg, ()) while 1: send_data = raw_input() if send_data in ['quit', 'Quit', 'QUIT']: s.send('Client Quit') thread.exit() s.close() s.send('Client : ' + send_data) | cs |
'Doing > Python' 카테고리의 다른 글
| 랜덤 뽑기 & excel 연동 (0) | 2017.02.01 |
|---|---|
| Canvas Flower (0) | 2016.12.27 |
| List Functions (0) | 2016.10.19 |
| 기초 문법(1) (0) | 2016.05.27 |
| 파이썬(Python)이란..? (0) | 2016.05.17 |
Comments