36. 36
Это один и тот же адрес:
• 192.0.2.235
• 0xC0.0x00.0x02.0xEB
• 0300.0000.0002.0353
• 0xC00002EB
• 3221226219
• 030000001353
37. 37
Пробуем..
ubuntu@qabs-school-infra-srv:~$ host yandex.ru
yandex.ru has address 93.158.134.11
ubuntu@qabs-school-infra-srv:~$ telnet 93.158.134.11 80
Trying 93.158.134.11...
Connected to 93.158.134.11.
Escape character is '^]'.
GET /index.html HTTP1.1
HTTP/1.1 400 Bad request
Content-Length: 0
Connection closed by foreign host.
ubuntu@qabs-school-infra-srv:~$ telnet 1570670091 80
Trying 93.158.134.11...
Connected to 1570670091.
Escape character is '^]'.
GET /index.html HTTP1.1
HTTP/1.1 400 Bad request
Content-Length: 0
Connection closed by foreign host.
51. 51
SMTP
ubuntu@qabs-school-infra-srv:~$ telnet mail.port25.com 25
Trying 69.63.149.30...
Connected to mail.port25.com.
Escape character is '^]'.
220 mail.port25.com ESMTP service ready
MAIL FROM: <test@port25.com>
250 2.1.0 MAIL ok
RCPT TO: <support@port25.com>
250 2.1.5 <support@port25.com> ok
DATA
354 send message
From: "Alex" <alex@port25.com>
To: "Support" <support@port25.com>
Subject: test message sent from manual telnet session
Date: Tue, 28 March 2014 13:12:57 +0400
Hello World,
Thx,
Alex
250 2.1.5 your message delivered
QUIT
221 2.0.0 closing channel
68. О каких компонентах речь
Как это происходит в сети
Покажите наглядно
Как это сделать
Протоколы
69. 69
RPyC: Пишем RPC-сервер
import rpyc
class MyService(rpyc.Service):
def on_connect(self):
# code that runs when a connection is created
pass
def on_disconnect(self):
# code that runs when the connection has already closed
pass
def exposed_get_answer(self):
return 42
def get_question(self):
return "Answer to The Ultimate Question of Life, the Universe,
and Everything?"
if __name__ == "__main__":
from rpyc.utils.server import ThreadedServer
t = ThreadedServer(MyService, port = 13404)
t.start()
70. 70
RPyC: Делаем RPC-запрос
>>> import rpyc
>>> c = rpyc.connect("localhost", 13404)
>>>
>>> c.root.get_answer
>>> c.root.get_answer()
42
>>> c.root.exposed_get_answer() # it can be accessed with the
'exposed_' prefix as well
42
>>> c.root.get_question() # but "get_question" is not exposed!
======= Remote traceback =======
...
File "/home/tomer/workspace/rpyc/core/protocol.py", line 298, in
sync_request
raise obj
AttributeError: cannot access 'get_question'
71. 71
Django JSON-RPC
from jsonrpc import JsonRpc, publicmethod
from django.core.urlresolvers import reverse
from django.http import HttpResponse
class MyRpcMethods(object):
url = reverse("myapp-rpc")
@publicmethod
def add(x, y):
return x+y
@publicmethod
def sub(x, y):
return x-y
def my_rpc_view(request):
rpc = JsonRpc( MyRpcMethods() )
result = rpc.handle_request(request)
return result
var rpc = new dojo.rpc.JsonService("/myapp/rpc/");
rpc.add(3,4).addCallback(function(result) { console.log(result);});
>>> 7
rpc.callRemote("sub", [9,5]).addCallback(function(result)
{ console.log(result);});
>>> 4