amorosik
Member
- Local time
- Today, 07:08
- Joined
- Apr 18, 2020
- Messages
- 540
I have an Access procedure, which I will call A which receives commands from another program which I will call B
Procedure A opens a tcp socket and listens on the indicated port
I use the classic MsWinsck.ocx, loaded between the references and then used in the code with the classic:
Set tcpServer = New MSWinsockLib.Winsock
tcpServer.Protocol = sckTCPProtocol
tcpServer.LocalPort = "12345"
tcpServer.Listen
Accompanied by the three events
Private Sub tcpServer_ConnectionRequest (ByVal requestID As Long)
Private Sub tcpServer_DataArrival (ByVal bytesTotal As Long)
Private Sub tcpServer_Close ()
that manage the arrival of a client, the arrival of data, the closure of the connection
Bon, everything works as expected, program A starts, then program B starts, from B I fire commands and A receives, as expected If B (the client) stays on and A turns off, on B's code there is a routine that tests the connection every x seconds and when I turn on A again, program B reconnects automatically, as requested
But, on the contrary, I can't intercept it, I mean if A (the server) stays on and B (the client) turns off, procedure A can't 'feel' that the connection is gone
I thought the tcpServer_Close () was triggered but it isn't
So the question is: how to understand from the vba code (the server) that the connection has been interrupted?
I thought about pinging from server to client periodically and it would already work, but I hope there is a more elegant system
What are you say?
Procedure A opens a tcp socket and listens on the indicated port
I use the classic MsWinsck.ocx, loaded between the references and then used in the code with the classic:
Set tcpServer = New MSWinsockLib.Winsock
tcpServer.Protocol = sckTCPProtocol
tcpServer.LocalPort = "12345"
tcpServer.Listen
Accompanied by the three events
Private Sub tcpServer_ConnectionRequest (ByVal requestID As Long)
Private Sub tcpServer_DataArrival (ByVal bytesTotal As Long)
Private Sub tcpServer_Close ()
that manage the arrival of a client, the arrival of data, the closure of the connection
Bon, everything works as expected, program A starts, then program B starts, from B I fire commands and A receives, as expected If B (the client) stays on and A turns off, on B's code there is a routine that tests the connection every x seconds and when I turn on A again, program B reconnects automatically, as requested
But, on the contrary, I can't intercept it, I mean if A (the server) stays on and B (the client) turns off, procedure A can't 'feel' that the connection is gone
I thought the tcpServer_Close () was triggered but it isn't
So the question is: how to understand from the vba code (the server) that the connection has been interrupted?
I thought about pinging from server to client periodically and it would already work, but I hope there is a more elegant system
What are you say?