-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
local service discovery test server local service discovery
- Loading branch information
1 parent
0dbe25c
commit 3843d93
Showing
3 changed files
with
33 additions
and
18 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# UPD server listening for a client broadcast and responding by giving its IP and name | ||
|
||
import asyncio | ||
import socket | ||
import json | ||
|
||
class Server: | ||
def connection_made(self, transport): | ||
self.transport = transport | ||
|
||
def datagram_received(self, data, addr): | ||
message = data.decode() | ||
json_message = json.loads(message) | ||
print('received : %r from %s' % (json_message, addr)) | ||
|
||
json_reply = '{"name": "panduza_platform","version": 1.0}' | ||
self.transport.sendto(json_reply.encode(), addr) | ||
print('send : %r to %s' % (json_reply, addr)) |
This file contains 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
This file was deleted.
Oops, something went wrong.