[Lazarus] FreePascal TCPIP data tunnel code sample?

Bo Berglund bo.berglund at gmail.com
Fri Feb 5 14:20:16 CET 2016


On Thu, 4 Feb 2016 21:10:54 +0100, Koenraad Lelong
<lazarus2 at de-brouwerij.be> wrote:

>Op 04-02-16 om 17:17 schreef Bo Berglund:
>> Then whatever data comes in through the Ethernet port should be sent
>> via the WiFi connection to the instrument.
>> All data received from the instrument should be sent out to the
>> connected client on the Ethernet connection.
>> So the program I am looking for should not do anything at all with the
>> data content, except transfer byte-by-byte between the networks.
>>
>> And this should be running on a Raspberry Pi2B so it can be easily
>> deployed in the place the instrument is located. Meanwhile I can sit
>> in another building and test the actual client code.
>>
>> Is there something like this available already?
>>
>>
>Hi,
>
>Isn't this just port-forwarding ? Set up the firewall to forward data to 
>the wired NIC to the device's address and port.
>
Which firewall?
But you are right in the port forwarding part. I want my new RPi2 unit
to forward the communications on port 1001 on the Ethernet side to a
specific unit on the WiFi side on its 1001 port.

The scenario is this:
- A device has a WiFi Access Point built in
- Clients connect to this AP via WiFi
- Then they can control the device via TCP port 1001
- The device is located in a remote building
- In the development lab there is no connection possible to the AP
- So I need a proxy of sorts in the remote building
- It should connect by WiFi to the device and its TCP port 1001
- It is also connected by Ethernet to the main network
- So a TCP server should accept incoming connections on port 1001
- Any data coming in on port 1001 from the Ethernet side should be
sent to the WiFi side to the device with the Access point
- Likewise data received from the device should be passed along to the
connected client on the Ethernet

After some research I have found that this is working just like a
proxy server and I found a component in Indy10 that can actually do
the entire thing!
It is named TIdMappedPortTCP and it does the following:
- Operates a TCP server on a designated port
- When a client connects to the port it opens a client connection to a
remote server (preconfigured server and port).
- Then data are channeled between the two sockets in both direction as
I described.

And all of this is available in a single Indy10 component!

I do have Indy10 installed in my Lazarus 1.6RC2 and I can see the
component on the palette.
Yet if I create a new console program and enter the used units for the
component Lazarus reports that it cannot find the unit!
Very strange, since it is installed and visible in Lazarus I assumed
that it would also be accessible from code...
Sigh....

-- 
Bo Berglund
Developer in Sweden





More information about the Lazarus mailing list