Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Python Korea Twisted Study 2013-06-30
Search
Bae KwonHan
July 01, 2013
200
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Python Korea Twisted StudyΒ 2013-06-30
Bae KwonHan
July 01, 2013
More Decks by Bae KwonHan
See All by Bae KwonHan
PyCon Korea 2017 micropython, led and thermostat
darjeeling
1
430
PyCon KR 2015 python and test
darjeeling
3
1.3k
PyCon.KR 2014 continuous luck and future
darjeeling
1
180
Featured
See All Featured
What's in a price? How to price your products and services
michaelherold
247
13k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
23k
Everyday Curiosity
cassininazir
0
290
Marketing to machines
jonoalderson
1
5.7k
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.6k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.4k
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
220
Crafting Experiences
bethany
1
260
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
550
Ten Tips & Tricks for a π± transition
stuffmc
0
170
Music & Morning Musume
bryan
47
7.3k
Transcript
Twisted for beginners λ°°κΆν 13λ 7μ 1μΌ μμμΌ
κ°μμ μμ μμ²λ릴 μ β’ κ°μλ£ λμ μ λΆλ΄κ°μ§ μλ κΈμ‘μΌλ‘
μνλκ³³μ κΈ°λΆλ₯Ό ν΄μ£ΌμΈμ. β’ λκ΅°κ° Twisted μ λν΄μ μλ €λ¬λΌκ³ ν λ©΄ μλ €μ£ΌμΈμ. β’ μ΄μ¬μλ₯Ό μν κ°μμ λλ€. κ³ κΈμλ μ λκ²λΆν° μμν©λλ€. 13λ 7μ 1μΌ μμμΌ
μ΄ κ°μμ λͺ©ν 13λ 7μ 1μΌ μμμΌ
μμΌνλ‘κ·Έλλ°μ μ½ λ€. 13λ 7μ 1μΌ μμμΌ
λͺ©μ°¨ β’ socket programming is? β’ socket client / server
β’ single socket β’ multi thread β’ generator β’ framework β’ gevent β’ tornadio β’ twisted 13λ 7μ 1μΌ μμμΌ
κ·Έμ μ .. β’ pythonbrew μ€μΉ β’ twisted μ€μΉλ₯Ό ν©μλ€. 13λ
7μ 1μΌ μμμΌ
κ°λ° νκ²½ μ μ β’ mac β’ xcode β’ homebrew β’
ubuntu β’ apt-get install build-essential 13λ 7μ 1μΌ μμμΌ
pythonbrew β’ https://github.com/utahta/pythonbrew 13λ 7μ 1μΌ μμμΌ
socket programming β’ UDP ( Datagram Sockets ) β’ TCP
( Stream Sockets ) β’ RAW ( RAW Sockets ) 13λ 7μ 1μΌ μμμΌ
μμΌμ νΉμ± β’ UDP β’ TCP β’ RAW 13λ 7μ
1μΌ μμμΌ
λ€νΈμν¬λ μ΄λ»κ² λ μ΄ μλκ°? β’ λΌμ°ν° β’ λ Έλ (
μ¨λ² ν΄λΌμ΄μΈνΈ ) β’ L4 β’ Proxy 13λ 7μ 1μΌ μμμΌ
network address β’ IPV4 β’ IPV6 : https://en.wikipedia.org/wiki/IPV6 β’ Private
Network β’ 10.0.0.0/8 β’ 172.16.0.0/12 β’ 192.168.0.0/16 13λ 7μ 1μΌ μμμΌ
network address β’ https://en.wikipedia.org/wiki/IPv4 β’ Special USE Addresses 13λ 7μ
1μΌ μμμΌ
IP Header 13λ 7μ 1μΌ μμμΌ
https://en.wikipedia.org/ wiki/IPv4#Header 13λ 7μ 1μΌ μμμΌ
β’ https://en.wikipedia.org/wiki/ User_Datagram_Protocol UDP 13λ 7μ 1μΌ μμμΌ
TCP β’ https://en.wikipedia.org/wiki/ Transmission_Control_Protocol 13λ 7μ 1μΌ μμμΌ
TCP Header 13λ 7μ 1μΌ μμμΌ
13λ 7μ 1μΌ μμμΌ
TCP μνκ° μ΄μ©κ³ .. 13λ 7μ 1μΌ μμμΌ
μ°λ¦¬λ μ΄λ°κ±° λͺ°λΌλ λ¨ 13λ 7μ 1μΌ μμμΌ
β’ μ°κ²° β’ μ¬μ© β’ λ β’ μλ¬ μ΄κ²λ§ μλ©΄
λ©λλ€. 13λ 7μ 1μΌ μμμΌ
κ·ΈλΌ νλμ© μ§λ΄ μ λ€. 13λ 7μ 1μΌ μμμΌ
μΉ νμ΄μ§λ₯Ό κ°μ Έμ€λ μμΌ νλ‘κ·Έλλ° 13λ 7μ 1μΌ μμμΌ
1 #!/usr/bin/python 2 3 import socket 4 5 s =
socket.socket() 6 s.connect(("ifconfig.me",80)) 7 s.sendall("GET /\n") 8 data = "" 9 while True: 10 buf = s.recv(1024) 11 if buf == "": 12 break 13 else: 14 data += buf 15 s.close() 16 print data 13λ 7μ 1μΌ μμμΌ
urllib 13λ 7μ 1μΌ μμμΌ
1 #!/usr/bin/python 2 3 import urllib 4 5 print urllib.urlopen("http://ifconfig.me").read()
13λ 7μ 1μΌ μμμΌ
κ·Έλ°λ° μ§κΈκΉμ§μ λ¬Έ μ λ? 13λ 7μ 1μΌ μμμΌ
1λ²μ 1κ°λ§ λ¨ 13λ 7μ 1μΌ μμμΌ
κ·ΈλΌ μ¨λ²λ μ§λ΄ μ λ€. 13λ 7μ 1μΌ μμμΌ
1 #!/usr/bin/python 2 3 import socket 4 5 s =
socket.socket() 6 s.bind(("0.0.0.0",9999)) 7 s.listen(1) 8 conn, addr = s.accept() 9 print 'Connected by', addr 10 while 1: 11 data = conn.recv(1024) 12 if not data: break 13 conn.sendall(data) 14 conn.close() 15 13λ 7μ 1μΌ μμμΌ
tornado 13λ 7μ 1μΌ μμμΌ
http:// www.tornadoweb.org/ en/stable/ 13λ 7μ 1μΌ μμμΌ
http://www.tornadoweb.org/ en/stable/ ioloop.html#ioloop-objects 13λ 7μ 1μΌ μμμΌ
about twisted 13λ 7μ 1μΌ μμμΌ
http:// www.aosabook.org/en/ twisted.html 13λ 7μ 1μΌ μμμΌ
β’ μμ¬ β’ socket β’ protocol β’ factory β’ process
β’ threads β’ logging β’ application β’ callLater / LoopingCall β’ database call β’ twistd 13λ 7μ 1μΌ μμμΌ
β’ 2002λ 첫 λ¦΄λ¦¬μ¦ β’ μ§κΈμ 13.0.0 μμ¬? 13λ 7μ
1μΌ μμμΌ
β’ Separation of protocols and transports β’ Deferreds β’ Thread
Support β’ Foreign Loop support νΉμ§μ 13λ 7μ 1μΌ μμμΌ
socket β’ http://twistedmatrix.com/trac/wiki/ FrequentlyAskedQuestions#HowdoImakein putononeconnectionresultinoutputonanoth er 13λ 7μ 1μΌ μμμΌ
code examples β’ http://twistedmatrix.com/documents/ 13.0.0/core/examples/ 13λ 7μ 1μΌ μμμΌ
writing servers β’ http://twistedmatrix.com/documents/ 12.2.0/core/howto/servers.html 13λ 7μ 1μΌ μμμΌ
run another process β’ http://twistedmatrix.com/documents/ 13.0.0/core/howto/process.html 13λ 7μ 1μΌ μμμΌ
threads β’ http://twistedmatrix.com/documents/ 12.2.0/core/howto/threading.html 13λ 7μ 1μΌ μμμΌ
application β’ http://twistedmatrix.com/documents/ 12.3.0/core/howto/application.html 13λ 7μ 1μΌ μμμΌ
logging β’ http://twistedmatrix.com/documents/ 12.2.0/core/howto/logging.html 13λ 7μ 1μΌ μμμΌ
callLater β’ http://twistedmatrix.com/documents/ 11.0.0/core/howto/time.html 13λ 7μ 1μΌ μμμΌ
database β’ http://twistedmatrix.com/documents/ 12.2.0/core/howto/rdbms.html 13λ 7μ 1μΌ μμμΌ
twistd β’ http://www.saltycrane.com/blog/2008/10/ running-twisted-perspective-broker- example-twistd/ 13λ 7μ 1μΌ μμμΌ