Re: Eunet or EuLibnet or TCP socket library (or socket.e)
- Posted by Spock May 19, 2016
- 2517 views
The client-server communications will be quite sparse (and the user load light). At client initialisation the previous few months transactions (for that user) will be loaded into the client as a single read-only table. When a new transaction is created in the client it gets sent to the server which then confirms the event. That is really the core of the transmissions. So on the client side I think it would work as a synchronous socket call that times out. The dropped TCP connection could be managed by preceding each call with a check that the connection is still up.
I don't think you need to keep the TCP connections open between the clients and server. This is the process I imagine you'd take:
# | Client | Server |
---|---|---|
1 | Connect to server | |
2 | Accept connection from client | |
3 | Send request for new transaction ID | |
4 | Receive request for new transaction ID | |
5 | Send new transaction ID to client | |
6 | Receive new transaction ID | |
7 | Send transaction ID and data | |
8 | Receive transaction ID and data | |
9 | Send SUCCESS or FAILED status | |
10 | Close client socket | |
11 | Receive status from server | |
12 | Close local socket |
This is how a lot of simple TCP protocols, like HTTP, work: the connection only lives for the duration of the request..
-Greg
This is even better by making each event independent. In the above table there is a user delay of a few minutes between items 6 & 7. So I could then break the transmission into 2 distinct chunks. And the server loop itself will be much simpler with no past/future to worry about - only the here and now.
Edit - In testing the client/server I discovered there is a buffer limit (in my case 1023 bytes). So files of arbitrary size can't be sent all in one go. Is there a standard solution to this?
Spock