How to establish a connection between two computers wirelessly? - python

Maybe is my question a little bit weird, but I am looking for an answer since couple days.
The only thing what I found were sockets and asyncio(dont really know what it is) , but with sockets you can establish a connection just in your localhost.
Is there any otherways to creat a connection between two quite different pcs or between a client and server wireless.
If you have any ideas just write, maybe it could be helpful. As a beginner in python, I would be happy if you guys could show me some way to find easy tutorials (maybe some websides) and important things to learn. So everything could be helpful, I am just curious. :)

You can create a server / client pair, through executables running on both PCs. TCP and UDP sockets can be used to communicate outside 'localhost'. You can do this rather easily in many programming languages like C, C#, python amongst others.

what you can do is create two seperate python files: client.py and server.py
The client.py will be trying making the connection. the server.py will be trying to receive that connection. You mentioned you weren't familiar with socket. Socket is a low-level networking interface when you import the library socket to a file, you are able to make system calls between different computers to interact with each other.

You need to install ros library form here for example if you have Ubuntu 16.04.
after that it is very easy to use those lines
We used this method with robots.

Related

How Can Python Socket Programming be used to tranfer data in Shared Hosting?

I am creating an application that uses the IOT/IOE (Internet of things) to communicate with sensors.
For this I have used Python Socket programming to Code the Sockets that communicate and JavaScript for the user end Display.
I am curious as to how I can implement this on a shared Hosting server? I know it is possible in a Dedicated Server where i have all the permissions.
If it is possible to use the sockets in shared hosting , I also want to know how feasible it is to do so ?
Any guidance will be appreciated. Thanks
If it is possible to use the sockets in shared hosting , I also want
to know how feasible it is to do so ?
As long as your socket end point is reachable in the Internet, you should be able to create and reach a socket just like the case of dedicated server. Typically, you should be able to request a public IP address on the shared host. Other than Internet reachability, sockets are application-layer semantics and so you don't need any special features.

How do I communicate between 2 Python programs using sockets that are on separate NATs?

I want to send and receive messages between two Python programs using sockets. I can do this using the private IPs when the computers are connected to the same router, but how do I do it when there are 2 NATs separating them?
Thanks (my first SO question)
You can't do it in general without a relay server on a publicly addressable IP address. There are so-called "punchthrough" techniques that can, in some cases, let you switch to a direct connection after using a public server to figure out port mappings - this article describes how the RakNet game networking library does it - but even these tend to be finicky and unreliable.
Zeromq, is the way to go. It is blazing fast and very easy. http://www.zeromq.org/
Redis, could work but not the exact same functionality.

UDP server to forward messages between clients

I'm starting to write an udp server to match two clients together and allow them to send/receive data to/from each other.
It's for a multiplayer game, and my goal is to create a p2p-like connection but with the intermediary server I'll make sure it will always work, even in cases where the user has a firewall, or is behind a nat.
The server should hande several matches (pairs of clients), I'm writing it in python and it's a bit harder than what I thought.
Is there any open source code for a server similar to this?
Take a look at the ZeroMq (0MQ) framework as an alternative to creating your own messaging. There's a python binding (pyzmq) for it.
This details how to write a UDP server in Python.

Decentralized networking in Python - How?

I want to write a Python script that will check the users local network for other instances of the script currently running.
For the purposes of this question, let's say that I'm writing an application that runs solely via the command line, and will just update the screen when another instance of the application is "found" on the local network. Sample output below:
$ python question.py
Thanks for running ThisApp! You are 192.168.1.101.
Found 192.168.1.102 running this application.
Found 192.168.1.104 running this application.
What libraries/projects exist to help facilitate something like this?
One of the ways to do this would be the Application under question is broadcasting UDP packets and your application is receiving that from different nodes and then displaying it. Twisted Networking Framework provides facilities for doing such a job. The documentation provides some simple examples too.
Well, you could write something using the socket module. You would have to have two programs though, a server on the users local computer, and then a client program that would interface with the server. The server would also use the select module to listen for multiple connections. You would then have a client program that sends something to the server when it is run, or whenever you want it to. The server could then print out which connections it is maintaining, including the details such as IP address.
This is documented extremely well at this link, more so than you need but it will explain it to you as it did to me. http://ilab.cs.byu.edu/python/
You can try broadcast UDP, I found some example here: http://vizible.wordpress.com/2009/01/31/python-broadcast-udp/
You can have a server-based solution: a central server where clients register themselves, and query for other clients being registered. A server framework like Twisted can help here.
In a peer-to-peer setting, push technologies like UDP broadcasts can be used, where each client is putting out a heartbeat packet ever so often on the network, for others to receive. Basic modules like socket would help with that.
Alternatively, you could go for a pull approach, where the interesting peer would need to discover the others actively. This is probably the least straight-forward. For one, you need to scan the network, i.e. find out which IPs belong to the local network and go through them. Then you would need to contact each IP in turn. If your program opens a TCP port, you could try to connect to this and find out your program is running there. If you want your program to be completely ignorant of these queries, you might need to open an ssh connection to the remote IP and scan the process list for your program. All this might involve various modules and libraries. One you might want to look at is execnet.

Writing a P2P chat application in Python

Is it possible to write a peer-to-peer chat application in Python?
I am thinking of this from a hobbyist project point-of-view. Can two machines connect to each other directly without involving a server? I have always wondered this, but never actually seen it implemented anywhere so I am thinking there must be a catch somewhere.
PS: I intend to learn Twisted, so if that is involved, it would be an added advantage!
Yes. You can do this pretty easily with Twisted. Just have one of the peers act like a server and the other one act like a client. In fact, the twisted tutorial will get you most of the way there.
The only problem you're likely to run into is firewalls. Most people run their home machines behind SNAT routers, which make it tougher to connect directly to them from outside. You can get around it with port forwarding though.
Yes, each computer (as long as their on the same network) can establish a server instance with inbound and outbound POST/GET.
I think i am way too late in putting my two bits here, i accidentally stumbled upon here as i was also searching on similar lines. I think you can do this fairly easily using just sockets only, however as mentioned above one of the machines would have to act like a server, to whome the other will connect.
I am not familiar with twisted, but i did achieved this using just sockets. But yes even i am curious to know how would you achieve peer2peer chat communication if there are multiple clients connected to a server. Creating a chat room kind of app is easy but i am having hard time in thinking how to handle peer to peer connections.

Categories

Resources