Coder Social home page Coder Social logo

yasinovskyy / networkzero Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tjguk/networkzero

0.0 1.0 0.0 11.62 MB

Making it easy for teachers to use simple networking in Python

License: MIT License

Shell 2.45% Python 95.04% Batchfile 0.08% C 2.44%

networkzero's Introduction

NetworkZero

image

Make it easy for learning groups to use simple networking in Python

API

address below refers to an IP:Port string eg "192.0.2.5:4567"

Discovery

  • address = advertise(name, address=None)
  • address = discover(name, wait_for_s=FOREVER)
  • [(name, address), ...] = discover_all()
  • [(name, address), ...] = discover_group(group_name, separator="/")

Messaging

  • reply = send_message_to(address, message, wait_for_reply_s=FOREVER)
  • message = wait_for_message_from(address, [wait_for_s=FOREVER])
  • send_reply_to(address, reply)
  • send_news_to(address, news)
  • wait_for_news_from(address[, pattern=EVERYTHING][, wait_for_s=FOREVER])

Typical Usage

On computer (or process) A:

import networkzero as nw0

address = nw0.advertise("hello")
while True:
    name = nw0.wait_for_message_from(address)
    nw0.send_reply_to(address, "Hello, %s" % name)

On computer (or process) B and C and D...:

import networkzero as nw0

server = nw0.discover("hello")
reply = nw0.send_message_to(server, "World")
print(reply)
reply = nw0.send_message_to(server, "Tim")
print(reply)

networkzero's People

Contributors

tjguk avatar tomviner avatar jelford avatar adamchainz avatar andreagrandi avatar cjrh avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.