New answers tagged

2

Use a Map Map<Integer, ClientThread> threads = new HashMap<>(); Add thread to map ClientThread thread = new ClientThread(socket); threads.put(thread.serverUniqueId, thread); Remove a thread threads.remove(id); Get a thread by id theads.get(id); Get threads by multiple ids int[] ids = {1,2,3,4}; for (Map.Entry<Integer, ClientThread&...


1

If you want to find something in an unordered array, iterating over it is the fastest thing you can do. You should store the Sockets in a HashMap. You can put in the id and get the corresponding Socket in constant time.


3

It sounds like your database comes in too early in the process. I would go with a light queuing solution maybe ZeroMQ? (not sure what you can run on your devices) the key thing I think is for the 'another software' respond directly to the message before putting it in the DB. That would reduce your database load to just inserts and allow you to scale up ...


0

So, just to be clear: every 5 seconds a tank will send its temperature to a server that stores it in a DB and then another server program will read this value and send a message to the tank to regulate its temperature? If so, the solution is quite simple: send the regulation command directly to the other IoT device that controls temperature, batch the temp ...


0

On the C side, you might consider using some message library, like 0mq. Perhaps you could be interested by JSONRPC or some JSON libraries like jansson (probably to be used above 0mq...), since node.js is likely to be JSON friendly.


3

If you're writing a program to track hours, then don't write it as a standalone command-based utility for a single machine. Just don't. Really. Don't. Instead write a REST server with authentication that can be reached from wherever you happen to be via our modern-day friend, the Internet. You can write the server in PHP if you'd like, or whatever you're ...


0

Seems I was indeed looking for the wrong tool for the job. Well, maybe message brokers can do the job, but there is an easier solution: HAProxy. HAProxy has a built in max connections settings for it's backend servers and will queue messages until the backend server can respond. It also supports connecting to Unix domain sockets (since version 1.5). In the ...


0

The most common way to use a SOCKS proxy server in the Linux world is to do so via a shared library that intercepts calls to standard socket functions and redirects them to the proxy server. This does not allow multiple connections to different servers, however (except by configuring different servers for different addresses, but that doesn't seem to be ...


0

An alternative approach may be, to make a simple manager web app and run it on a local web server. As it's a web app, it can be accessed from a tablet, pc, phone or whatever. Admins(workers) select which computer should play which video, from the manager web app's gui. Client apps check the web app periodically (say once every 5 seconds) too see if ...



Top 50 recent answers are included