How to set up a tcp server on a personal computer - python-3.x

I'm not that experienced with networking - hence why I'm asking this question - so please have patience with my inexperience.
What I want to do is set up a server on my computer that my friend's computer could connect to through the internet and we could play a game (very surprising indeed). A vague idea that I had was I could run a VM to handle it. My questions are:
Is there a way I could establish a connection between our computers without having to pay for a separate server?
Is there a Python 3 library that's good for beginners (in networking - not Python) that can do this task?
Note 1: It is a turn based game so the processing does not have to be really fast.
Note 2: I have a basic understanding of sockets, servers, etc, I'm just not familiar enough with them to find what I'm looking for elsewhere.

Are you familiar with netcat? What do you mean by "(in networking - not Python)". The reason I ask if your familiar with netcat is because if you are sockets should not be too hard to program (I say that respectfully they can be weird at first glance). Your most likely going to have to open a port on your router to do this. Depending in the game will be the complexity of programming this. But basically this is what you want right.
TCP Server (Listening) (Your Friends House)
TCP Client (You)
TCL Client -> TCP Server
If your gonna be using a windows gui just use VNC Viewer: https://www.realvnc.com/download/viewer/ or TeamViewer: https://www.teamviewer.com/en/ or enable RDP.

Related

Website for Minecraft Server Wake Up on Lan

a friend of mine has a little server rig. He hosts a Minecraft-Server on it over his router at home. Because he doesn't wanna run it 24/7, I had an idea and I wanna ask if its possible.
My idea was to create a little website (world wide web) to start the server over wake up lan. I would run the website on my Rasperry Pie, which would be online 24/7.
Is that possible? If so, what should I learn to make the website safe, e.g. password?
Im not very familiar with website coding, but Im pretty good with software development with C-Based languages.
Im non-native speaker, so please excuse any grammar mistakes.
Thank you.
Wake on LAN works using broadcast packets, so in the local network only
And by default your router blocks those packets from the outside
You will have a bad time trying to make that works
In your case, the best choice would be to pay a little server online for your server

how to communicate with my apps using IP address and socket remotely

I am to Electron and nodejs
And stuck here, actually i m making a desktop app to control every PC in network. which tells me the ip and mac of computers in the network. But now I need to talk to it and push/get some message. but how ?
Socket.io is likely the easiest way to do what you are trying to do. It'll allow you to communicate between the machines with a relatively low amount of effort.
Sockets generally work on a "server" and "client" basis, so you may want a central server that will coordinate with the clients.
This blog post from node source provides a really good intro to using them.

communication between processes: tcp vs unix sockets, ipc vs nats

I'm breaking a big application into several processes and I want each process to communicate with each other.
for now it's gonna be on the same server, but later several servers on same local network will have several processes that will need to communicate between each other. (means service on one server, with service on other server on same vpc)
so.. my raw options are tcp or unix sockets. I know that with Unix sockets can be useful only if you're on the same server. but we're thinking about writing our own implementation that on same server processes will communicate on unix sockets, and between servers that will communicate using tcp.
is it worth it ? of course tcp sockets are slower then unix sockets.. cause it doesn't go through the network and doesn't get wrapped with tcp related data. the question is by how much ? I couldn't find online proof of benchmarking between tcp and unix sockets. if tcp adds 3%-5% overhead that's cool, but can it be more then that ? I'd like to learn from experience of big projects.. of other people over the years, but didn't find anything relevant.
next...
our project is a NodejS project.
some people may say that I can use a broker for messages, so I tried using nats.io compared to node-ipc (https://www.npmjs.com/package/node-ipc) and I found out that node-ipc is 4 times faster but nats has the cool publish-subscribe feature... but performance is important.
so I have tons of options, no concrete decision.
any information regarding the issue would be greatly appreciated.
The question is actually too broad to answer, but one answer for TCP vs unix domain sockets:
Architect your code, so that you can easily move between those if necessary. The programming model for these is basically the same (both are bidirectional streams of data), and the read/write APIs on OS level as well as in most frameworks is the same. This means e.g. in node both will inherit from the Readable/WriteableStream interfaces. That means the only code that you need to change for switching between those is the listener on the server side where you call the TCP accept APIs instead of the unix domain socket accept APIs and the other way around. You can even have your application accept both types of connections and later on handle them the same internally.
TCP support is always nice because it gives you some flexibility. With my last measurement the overhead was a little bit more (I think 30% versus TCP over loopback) but these are all micro benchmarks and it won't matter for most applications. Unix domain sockets might have an advantage if require some of their special functions, e.g. the ability to send file descriptors across them.
And regarding TCP vs NATS & Co:
If you are not that experienced with network programming and protocol design it makes sense to use readymade IPC systems. That could be anything from HTTP to gRPC to Thrift. These are all point-to-point systems. NATS is different, since its a message broker and not RPC. It also requires an extra component in the middle. Whether this makes sense totally depends on the application.

SSL Socket Communication in CGI a good idea?

I would like there be a way to communicate between and Apache Server and an Application running on a Linux laptop.
The only way I can think of doing this is using SSL Sockets in a CGI python or perl script. Is this a good idea by any chance?
The Apache Server and the application are on the same machine, so perhaps having encryption might not be a big deal, since an attacker would need to gain physical access to hack the process. On the other hand it is connected to the network, and possibly could be sniffed.
Is encryption in such a case? Could an attacker sniff the data in that case?
Also if this is indeed a good idea, does anyone have resources on how to implement ssl socket with perl or python?
If you are using loop back address (local host or 127.0.0.1), i don't think it can be sniffed on the network since it doesn't go beyond your interface card. So encryption is not a concern here.
For the second part, following is an SO example python client though uou can find tons any way.
Another thing is being on Linux, you can simply connect via shell too. Just use netcat i.e. nc. You can send any text to server as well as read back using this command line application.
Don't reinvent the wheel.

Listening a particular port on linux to access data comes from mobile device

i am newbie to Linux platform, i am working on java technology.
what i have to do is : Having a program that running on mobile devices,that sends some data to my Linux machine, now i have to create a program in java that
listen to a particular port.
access data comes on that port(which is sending by mobile device)
save that data to the database.
response back to the mobile device.
i.e. i would make my Linux system as server that can listen from many clients(mobile devices), but not getting how to configure this environment... :(
i used cent OS 5.4 and
installed jdk1.6.0_24
any help would be appreciated.....
thanx in advance!
khushi
One of Java's greatest strengths is that you can pretty much ignore the host operating system as long as you stick to core Java features. In the case you're describing, you should be able to accomplish everything by simply using the standard Java networking APIs and either the JDBC to access an existing, external database or you could choose any number of embedded Java databases such as Derby. For your stated use case, that you'll be running the application on Linux is pretty much irrelevant (which should be good news... you don't need to learn a whole operating system in addition to writing your app ;-).
Here's a nice client/server tutorial, in that it is broken into steps, and adds each new concept in another step.
Here's another client/server tutorial with much more detail.
I would write it to accept one connection at a time. Once that works, I would study the new(ish) java.lang.concurrent classes, in particular the ExecutorService, as a way of managing the worker bee handling each connection. Then change your program to handle multiple connections using those classes. Breaking it up in two steps like that will be a lot easier.

Resources