A
A
Alexey Terentiev2014-07-28 18:10:23
Frameworks
Alexey Terentiev, 2014-07-28 18:10:23

Is there a simple solution that would listen on a given port, be able to handle many connections at the same time and keep the session as long as possible?

Friends, tell me the option (platform, language, framework, ready-made open source solution).
Task.
There are many devices (hardware) that are installed in the cars (in each), they all have modems (i.e. Internet access. There will be exactly 5000 such devices (and there will be no more!)
There is a server (the platform can be any, it is not so important, it is important to do it as quickly as possible, i.e. on the OS on which it will be easier).
There is an operator (a living person, even with a higher education), who has a list of these devices on the browser screen and an interface that allows you to display the current status of each device and allows you to change settings and send to the device (I repeat, through the browser). A connection must be established between the device and the server (from which the browser loads the page). The device can send something important at any time (for example, that the temperature in the boiler is high, or an accident in the toilet pipeline, etc.). The device itself tries to be in touch, i.e. connected to gprs internet. The operator (the same one with a higher education) can also suddenly send a command and the device, having received it, executes it and replies that everything is done.
Each device has its own unique number (IMEI for a modem) and this number must be present in the packet from the device (i.e. the server must know from whom the packet came and can save the data in the line corresponding to this device in the BD table).
So these are all wishes.
Question: is it possible to do this with PHP or do I need something else? (so far it hasn't worked out in PHP)
If it's different, then where to dig? Is there something more elegant and reliable?
Tried with sockets in PHP, but sockets break the connection. At the same time, if the connection breaks, then the operator rounds up the traffic during the session up to 1 kb or 10 kb or 100 kb, depending on the tariff.
In addition, it must be taken into account that the device can pass through the "blind" zone, i.e. where the device cannot get in touch (there is no GSM signal), this is especially applicable in Russian Railways, where towers are located near roads, but not near railways.
Strictly TCP packets (i.e. guaranteed delivery). In addition, the recipient responds to each packet (acknowledgement is mandatory!), They say he received it, everything is ok. If not, then retry to send the data.
The operator has an indication of who is online and who is not. I mean, you don't need to break the connection yourself. And to the fact that if the operator (with a higher education) decides to change something, then you must first save it in the database, and when the device appears online, the device will say that it is online and it needs to shove the configuration packages (all this except for the communication is not a problem and has already been done). The same goes for the device, it can accumulate data during its stay without the Internet and merge several data packets after connecting (this is also ready). Devices can communicate at any time.
There can be many devices at the same time (no more than 5000, but it is clear that everyone will not attack at once with their data).
Is there a more elegant solution to my problem than sockets?
Maybe there is something to read?
Has anyone already done something similar?
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2014-07-28
@begemot_sun

Erlang is ideal for any highly loaded network demons. Any PHP will not suit you (not that level).
Of course, you can take C \ C ++ and by long and dreary programming using semaphores, mutexes, etc. get the desired result, but this is a slow way, you can do it faster (see above).
I can personally make such a daemon for you in Erlang. Nothing will fall, nothing will leak. Everything will work like clockwork. If you are interested, then write to me by mail - contacts in the profile.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question