Best practices for client-server communication - sockets

I am busy creating a system where various PCs communicate with each other over the internet. How it works at the moment, is each PC is a client and logs onto the server. Currently, there is a normal java program running on my own server with listening sockets that handles incoming requests and then relays the information between the connected PCs. My question is, is this a proper way of doing it? Should I rather change the app to a service or should I use something like a webservice? Also, is it fine using TCP sockets for the communication?
If I don't want to run the program on my own server, what type of company can offer me such a service where I can run my own apps?
I want to expand the current setup to a larger scale, so I want to make sure I am using good practices and keep hackers out.
Thanks

Related

What type of protocol should be used to communicate with another computer?

I have a site and I want to allow users on that site to send information over to a second computer. That second computer would then take the information and make a physical robot do something.
The front end consists of an angularJS web app with a node.js server so that any device connected to the second computer can make the robot do something.
I'm struggling with what protocol to use in order to communicate with the second computer from the website. I tried using TCP but there were firewall issues and it doesn't seems hacky. I am thinking of either using REST or websockets but I am not sure which protocol is best suited for what I'm trying to do.
Thanks.

TCP based decentralised chat app in C

I need to make TCP based decentralised chat app for local network. By decentralised I mean there is no central server. Each entity on a network should have server/client architecture. When app starts it should check which user is online ( already running the app ). My question is how can i check that? Can i do it by trying to connect via connect() function from socket library? I'm new to programming, especially socket programing, so if it's a dumb question sorry in advance.
You should definitely study how other decentralized applications do this. There are lots of techniques.
Each instance of the application should, as part of its server functionality, track the addresses of other instances of the application. Each instance should, as part of its client functionality, keep track of a few instances it can connect to. Prefer instances that have been around for a long time.
The software should include a list of servers that have been running for a long time and are expected to typically be available. You may wish to include a fallback method such DNS, maintained by anyone willing to keep a list of well-known servers offering access through a well-known port. The fallback method can also be IRC or HTTP.
If you want to stay decentralized, you might want to try multicasting or broadcasting a request packet to all hosts on the network to discover other instances of your chat application.
Something similar has been implemented in Pidgin, named Bonjour. It works quite nicely and provides chatting capabilities on a local network. More specifically, it is defined as a Serverless Messaging part of XMPP.
If you are looking for code examples, have a look at one of my projects where I use multicast to discover hosts on the local network that provide a specific service: Headers and implementation.

Push notifications with sockets for desktop WPF aplication (No Win8 App)

I'm trying to get into an implementation of some kind of push notification for a Windows WPF client application and a java backed server.
The idea is to avoid as much as possible polling the server, so I thought to implement it with sockets and messages, and relying in some easy pulling solution in case a socket connection could not be done, (Firewalls, etc).
In the other hand is important that the data traveling get encrypted.
So I have a couple of question/"request for opinions" more related with the WPF client:
Perhaps already exist some solution for that, any tips?
Could be good to think in some SSL sockets connections for that?
If 2 is OK, there is some native solution for secure sockets in .net or any library?
If sockets solutions is an option, I guess i need to go through port 443 and by the way it will avoid many problems with firewalls and so on, am i right?
I know there is many question but all are related to the same problem.
Thanks in advance.
http://clientengine.codeplex.com/
Yes, SSL is good if you need to keep the data secure during transfer
Yes, http://clientengine.codeplex.com/ indicates it supports SSL/TLS
Well, it depends on whether you are controlling the server or not. If you have control over it you can use whatever port you want.

Simulating Virtual Users for Smartphone App based Service

Apologies if something similar has been asked in the future but my search didn't return, what I would consider, directly related.
I am trying to implement a service with its backend in AWS EC2/S3 and front-end in iPhone and the service is more or less like a todo-list. This is not a novel idea but will help me in a class I teach about IT infrastructure.
Unfortunately I have access to only my own iPhone and I cannot demonstrate scalability over AWS, etc.
Is there a way/software tool/framework to simulate virtual users for this app that can send requests to the AWS servers pretending to be from different accounts/apps?
The simulator should send requests just like my actual iphone app would send if I were to add an item to the list or delete or edit.
I understand stress testing is a well established topic but here I want to just simulate multiple users and demonstrate scalability instead of trying to push the Web service to its limits. Neither am I sure if this completely overlaps with traffic simulation.
Any help will be deeply appreciated.
You might be able to do it using Apache JMeter. That depends on what you have going on on the backend. But it supports the following server types:
Web - HTTP, HTTPS
SOAP
Database via JDBC
LDAP
JMS
Mail - SMTP(S), POP3(S) and IMAP(S)
Native commands or shell scripts
You should be able to wire something together with that.
http://jmeter.apache.org/
http://www.opensourcetesting.org/performance.php
I've used it at various points to simulate VERY heavy loads for my services running in AWS/EC2.
Apache Benchmark is a very convenient tool for doing HTTP load testing -- you can have it make concurrent requests to simulate multiple users. It's main advantage over other tools is that it's simple and easy to get started with. If your backend listens on HTTP, it might be worth trying ab before investing any time in something more complex.

socket programming beginner

Lets say I have a tablet PC running a GUI application, and a remote PC (with static IP) running the backend core stuff.
The application running on the PC should request information from the Server.
Now I was thinking of socket programming, where the server will be running a server socket application and the tablet PC a client socket application.
But is there a simpler thing? I know ftp protocol is used to transfer files, is there a high level protocol like ftp that can be used to transfer small binary data, 16 bits per request? so I don't have to do any socket programming?
If the answer is only using socket programming, how to do that?
If I understand correctly, what you really want is an Application Server. If you choose to use sockets, you will have to deal with a lot of low-level details, such as marshalling / unmarshalling. You can opt for a higher-level solution:
CORBA;
PHP-based web server, perhaps using REST for transferring requests / replies;
add your favourite RPC / RMI framework here.
Socket programming is indeed what you want here. Check out Beej's Guide to Network Programming to get yourself started.