Kubernetes Addendum
In the previous post – Kubernetes Follow-On (Part 4) – I mentioned how the IP Address
selection might be backwards. That is,
the instantiation of the Socket Server might be selecting the IP Address that
should be used by the Socket Client and vice versa.
So I went
ahead and created an Ada App3 to execute on a second PC with the
RemoteComponent to communicate with the Component2 of the App2 Ada project and
then, after getting that working, I added to the C# NewComponent the code to communicate
with the App3 RemoteComponent. This
later required that the Delivery.dat file have this new pairing added to it.
First in
the Ada App2 and the new App3 the IP Address selection had to be reversed to
allow the two components to communicate with each other. Then with the trial extended to between the
C# NewComponent and the App3 RemoteComponent, the IP Address selection also had
to be reversed in the C# Socket Server and Socket Client. 50% chance of having the selection correct
and the coin landed the wrong way up.
(Note: Until the other PC got involved all the IP Addresses were the
same so it didn't matter which was selected.)
App3 is almost a clone of App2 so no need to provide the
code here. Just with RemoteComponent
replacing Component2 of App2. The
Delivery.dat file already provided the pairing between these two
components. For the C# application, the
pair of records to provide the names, IP Addresses, and ports for the
connection had to be added to Delivery.dat.
And the NewComponent was modified to also request communication between
it and the RemoteComponent of the other PC with its different IP Address. Nothing new requiring the code to be
displayed.
The changes to the Socket Server and Socket Client are
simple enough.
The only change to Socket.Server.adb of Ada is that
IPAddress := Delivery.IP_Address(MatchIndex);
in the Request function is changed to
IPAddress := Delivery.IP_Address(Partner);
to use the IP Address specified for the opposite component
of the pair.
Similarly for Socket.Client.adb,
IPAddress := Delivery.IP_Address(MatchIndex);
in the Request function is changed to
IPAddress := Delivery.IP_Address(Partner);
after Partner was declared after MatchIndex
MatchIndex : Delivery.LocationType;
Partner :
Delivery.LocationType;
and obtained from the Delivery package via
-- Set
the IP addresses and the ports.
if
MatchIndex > 0 then
Partner := Delivery.Partner( MatchIndex );
as in Socket.Server.
For the C# application, SocketServer.cs was changed from
SocketData.ListenerData.list[Count].ToAddress =
Delivery.DeliveryTable.list[Partner].IP_Address;
to
SocketData.ListenerData.list[Count].ToAddress =
Delivery.DeliveryTable.list[MatchIndex].IP_Address;
and SocketClient.cs was changed from
SocketData.SenderData.list[Count].FromAddress =
Delivery.DeliveryTable.list[MatchIndex].IP_Address;
to
int Partner = Delivery.DeliveryTable.list[MatchIndex].Partner;
SocketData.SenderData.list[Count].FromAddress =
Delivery.DeliveryTable.list[Partner].IP_Address;
That's all there was to it.
No comments:
Post a Comment