B4J Question Wich differences from Socket/jNetwork vs MsWinsck.ocx of Microsoft ?

amorosik

Expert
Licensed User
I have a procedure, which I will call A, made in Microsoft Access environment that I use as a socket server, uses the MsWinsck.ocx control
A second procedure, which I will call B, also implemented in Access, which is used to send information to procedure A
I would like to replace procedure B with a program, which I will call D, made in B4J because I believe it has better functionality
I then wrote program D in B4J code to perform the same operations that were previously performed by B
Program D connects successfully to server A, sends data, disconnects and reconnects successfully
There is only one difference with the original program B and it is the inability of server A to 'hear' the disconnection
When program D is shut down abruptly, for example using the Windows task manager, server A does not 'hear' the disconnection of client D
And this anomaly is particularly serious because it prevents the server from accepting subsequent reconnections from client D
Keeping the connection open is necessary because even the server can return information to the client and therefore it is not possible for me, client side, to open a connection, send information, and close
This is a video that allows you to quickly understand what I am requesting
In attach the sources of program A, B, D

So the question is: what are the differences between the socket / jnetwork library compared to the MsWinsck.ocx and how to make the server 'hear' the interruption of the connection (like using Microsoft Access client, program B)
 

Attachments

  • ServerA_ClientB_ClientD.zip
    477.8 KB · Views: 190

Star-Dust

Expert
Licensed User
Longtime User
If the disconnection is ordered then occurs with a close, it is perceived. If you kill the client with the Real manager this does not happen.

As.(Erel) has already written, in this case only by sending data.As(Ping) would you detect the closure.

But more also give the server the ability to receive more client connections than the next node that its not rejected.
 
Upvote 0

amorosik

Expert
Licensed User
The only reliable solution is to periodically send a "ping" message and if there is no response after X seconds, assume that the connection is broken.

I understand, but using the client in Access when it is shut down, the server 'sees' the disconnection
And so this makes me think there is a chance to do it
This means that the connection activated by the Access client has something different from the one activated by the B4J code
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
Maybe you can close the socket at the request to close the Form. It is not said that it will be raised when you close it with Task Manager ... but it could work.

In any case Access closes the socket for this the server notices the disconnection
 
Upvote 0

amorosik

Expert
Licensed User
If the disconnection is ordered then occurs with a close, it is perceived. If you kill the client with the Real manager this does not happen.

As.(Erel) has already written, in this case only by sending data.As(Ping) would you detect the closure.

But more also give the server the ability to receive more client connections than the next node that its not rejected.

"...If the disconnection is ordered then occurs with a close, it is perceived..."
No, this is not true
If you kill Access socket client WITH TASK MANAGER, so without a proper closing sequence from code, the server 'sees' the shutdown
In the video at the 37th second
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
It is part of the TCP / IP protocol which communicates disconnection when closed. So it is a fact that if it does not feel closure, this is not an orderly closure.

If in the case of access it hears it after 37 seconds, it could be that the client is sending a PING as Erel has assumed.

In any case you can do some tests by sniffing your own network and see what happens at the moment of disconnection.
Unfortunately the Access files you sent me don't work, otherwise I would have already tried it. Maybe we have different versions.
If you do this test you can see what happens at the 37th second
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
I am sending you some links that explain that there is no way to perceive the disconnection if the close is not used.
If not sending data it goes in error, as mentioned by Erel


 
Upvote 0

amorosik

Expert
Licensed User
It is part of the TCP / IP protocol which communicates disconnection when closed. So it is a fact that if it does not feel closure, this is not an orderly closure.

If in the case of access it hears it after 37 seconds, it could be that the client is sending a PING as Erel has assumed.

In any case you can do some tests by sniffing your own network and see what happens at the moment of disconnection.
Unfortunately the Access files you sent me don't work, otherwise I would have already tried it. Maybe we have different versions.
If you do this test you can see what happens at the 37th second

I don't know how to 'see' what the two programs exchange
What is wrong with the sources I sent?
 
Upvote 0

amorosik

Expert
Licensed User
Actually the Access vba code 'feels' the connection dropped, if I set a timer to 1 second and I query the socket property "tcpServer.State" I see that, when I turn off the client, it changes from 7 (SCK_CONNECTED) to 9 (SCK_ERROR)
The real problem is that the tcpServer_Close event is not triggered as I would expect
I am currently working on the server side checking the connection status every second, but I hope we can do better than polling
 
Upvote 0
Top