먼저 다른 사람의 기존 XMPP library을 사용하여 직접 작성하십시오. 벌써 많이있다. SleekXMPP으로 시작하십시오.
질문에 답변하려면 Start-TLS를 수행 할 때 ssl.wrap_socket으로 전화하십시오.
import socket
import ssl
sock = socket.create_connection(("example.com", 5222))
sock.write("""<stream:stream
to='example.com'
version='1.0'
xml:lang='en'
xmlns='jabber:client'
xmlns:stream='http://etherx.jabber.org/streams'>""")
sock.recv(1000) # reads the stream:stream and stream:features. Obviously bad code, to get the point accross
sock.write("<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>")
sock.recv(1000) # read the proceed
ssl_sock = ssl.wrap_socket(sock)
ssl_sock.write("""<stream:stream
to='example.com'
version='1.0'
xml:lang='en'
xmlns='jabber:client'
xmlns:stream='http://etherx.jabber.org/streams'>""")
등
: 예를 들어,