GithubHelp home page GithubHelp logo

akka-p2p's Introduction

akka-p2p

A minimal peer-to-peer server written in Scala, using Akka Streams.

Try it

Locally

First, download akka-p2p using git

$ git clone https://github.com/awwsmm/akka-p2p.git
Cloning into 'akka-p2p'...
remote: Enumerating objects: 103, done.
remote: Counting objects: 100% (103/103), done.
remote: Compressing objects: 100% (71/71), done.
remote: Total 103 (delta 33), reused 91 (delta 21), pack-reused 0
Receiving objects: 100% (103/103), 22.34 KiB | 693.00 KiB/s, done.
Resolving deltas: 100% (33/33), done.

Then, cd into the akka-p2p directory

$ cd akka-p2p

Then, run with sbt

$ sbt -error run

akka-p2p> help
broadcast => broadcast a message to all peers
connect => connects to a peer
disconnect => disconnects from a peer
help => prints this help text
logout => disconnects from all peers
quit => quits zepto
send => send a message to a peer

akka-p2p> 

The -error flag hides all compilation output except for errors. Omitting this flag will show compilation log lines.

Open another terminal and create a second akka-p2p instance with sbt run again. (But first, you'll need to change the port.)

$ cd akka-p2p

$ export AKKA_P2P_HTTP_PORT=3002

$ sbt -error run

akka-p2p>

Connect to a peer

Connect to a peer with the connect command

$ sbt -error run

akka-p2p> connect localhost:3001

akka-p2p>

And send a message with the send command

akka-p2p> send localhost:3001 hi from localhost:3002
Attempting to send message "hi from localhost:3002" to peer at localhost:3001

akka-p2p>

Your peer will see

akka-p2p> localhost:3002: "hi from localhost:3002"

akka-p2p>

Troubleshooting

ERROR | Bind failed for TCP channel on endpoint [localhost/127.0.0.1:3001]

If you're seeing the above error, it means the port you're trying to use for akka-p2p (in this case 3001) is already in use by another process.

You can set a custom port for akka-p2p with

$ export AKKA_P2P_HTTP_PORT=5555 # or whatever

Then just run akka-p2p as normal

$ sbt run
...

akka-p2p>

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.