Comments (1)
I do not understand what you are trying to do. Are you hacking the TcpServerNode.py or implementing a new node? The classes already build up a peer-to-peer network and if a node gets a request you can simply respond to it. It is a raw implementation, while you need to implement the networking packets yourself (like discovery). The best way to implement your own peer2peer node is to do the following:
class MyNode (TcpServerNode.Node):
# Python class constructor
def __init__(self, host, port):
super(MyNode, self).__init__(host, port, None)
print("MyNode: Started")
# Method override, implement here your own functionality
def event_node_connected(self, node):
print("p2p_event_node_connected: " + node.getName())
def event_connected_with_node(self, node):
print("p2p_event_node_connected: " + node.getName())
def event_node_inbound_closed(self, node):
print("p2p_event_node_inbound_closed: " + node.getName())
def event_node_outbound_closed(self, node):
print("p2p_event_node_outbound_closed: " + node.getName())
# If a message comes in, determines what to do!
def event_node_message(self, node, data):
print("p2p_event_node_message: " + node.getName() + ": " + str(data))
The event methods you can use to communicate with the nodes that are connected. It is a true peer2peer network, so you do not have any idea how big the network is. The only way to do that is implementing a discovery function. See for another example AvansNode.py in the examples directory.
from python-p2p-network.
Related Issues (20)
- I have question about the "nodeconnection.py" HOT 1
- I have link question between "node.py" and "nodeconnection.py" HOT 2
- Pip3 version is out of date and unstable HOT 2
- how HOT 1
- how to HOT 1
- how to use send_to_node api? HOT 2
- Import "p2pnetwork.node" could not be resolved HOT 1
- Connect to a node already connected to HOT 3
- Bug in connect_with_node function in node.py HOT 2
- implementing compression to transfer large files over socket. HOT 11
- Change to Tox testing suite HOT 3
- New feature: Plugins HOT 4
- Length protocol instead of EOT HOT 13
- Issue: unit test test_node_max_connections failed HOT 2
- Info about node discovery HOT 3
- OS Error when stopping nodes HOT 1
- Non UTF-8 messages will throw exception
- Crash if node id malformed HOT 1
- Misspelled debug messages
- Hello, how to implement the broadcast and discovery of nodes?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-p2p-network.