Forum > Networking and Web Programming

multisocket with lnet component - how do this

(1/5) > >>

jolix:
Hi,

Solved questions posted on this forum, is time to next war.

My application should open and talk with until maximum 32 sockets (32 different IP) each one is an tcp server electronic module.
Those modules are placed in different places in my home and my garden.

This amount of different sockets are to much to have 32 software modules, so the ideal is to have some sort of index for access those modules in circular way.

Someone in this forum with knowledge enough is capable to elucidate me about it?
Can i do it with LNet ?

Thanks in advance

Jo

Almindor:
Do I understand it right that you need 32 separate servers? If so you can make an array or list of them. You can still use the "visual" ones (if you use forms) but make sure to assign the form as parent otherwise it won't work. You can share the event callbacks on them too, just make sure to use the aSocket parameter to handle replies etc.

jolix:
Before anything else, many thanks Almindor.

Back to the topic, yes, you have understood right, i have 32 TCP/modules with an unique IP/Port for each one.
Additionally, i can configure destination IP/Port that is the IP of my PC.

You have made some suggestions that i understand  it formally but not in practice, because my experience is on microcontrollers, not pc software.

So how do i index sockets as you are you suggesting?, taking in account that all modules and consequetly, all sockets must remain open.

About assign form as parent, since i work in the main form, is implicit that is parent!?

Regards,
Joli

Almindor:
Ok, before we go any further I need to know why you need 32 separate servers and not 1 server with 32 sockets in it.

Do you need different port for each of the incoming connection? If you need 32 connections on same port then you're mixing things up a bit, and just need one server with 32 sockets in it. If that's the case then all you have to do with lNet is use the OnAccept event and "store" the socket (from the aSocket parameter in the procedure) into some list with some sort of identifier (you can use a TStringList.Objects or other lists/maps for this).

If you really need 32 different ports opened then you need 32 TLTcp servers listening on them, best is to use an array. Specify what you need first tho before we get into code.

jolix:
Hi Almindor,


--- Quote ---Ok, before we go any further I need to know why you need 32 separate servers and not 1 server with 32 sockets in it.
--- End quote ---

Instead of trying to explain things for wich i'm very green, perhaps is more interesting to describe the system.

For instance, in different places of my home, i will have tcp/ip modules to collect the temperature.
Additionally, each one have one output to control air conditioner equipment (on/off).

Each module is configured as a server and have one ip/port that i can modify.
Through this socket, my program sends commands to inquire what temperature is or send commands to tell the module turn on/off air conditioner.

Additionally, i can configure on each module the ip of my pc and port by wich the program will receive or listen.

Even before test, because right now i have just one module, as a result of module beaviour, i suspect that i can have all modules with the same ip but with different ports.
I will have shure about it, just in a few days from now.

The question you put about, why not configure modules as a client, well is my program that allways assumes the iniciative in terms of stablish connection and communication too.
My module just acepts connections and commands from my pc.
Working like this i though the module is server. Tell me if i'm wrong.

Regards,
Jo


Navigation

[0] Message Index

[#] Next page

Go to full version