delphi - TIdTCPServer reconnection for the same login user -


my server build on tidtcpserver should capable 1 single connection 1 user @ same time. searched lot can't find resolve.

everything looks correct if there no errors, mean: @ begining client sends login , password, methods onconnect or onexecute check ok , user connection same name dosen't exist. if ok exchanging of messages starting. if not, method fo disconnection calling.

but, when such remote application (written using other tools indy) unintentionally lose connection (due temporary loss of network) server not know immediatly , thinks ok. @ same time client application knows there error. when network connection again, client application attempts connect server attempt rejected (by server) because server keep last connection user (until time when connection close on error event).

is there way of bypassing problem of rejection after quick resuming connection without rejecting 2 (last , actual attempted connection same client clear information loged user) give him possibility until next attept?

i use trick "heartbeat" checking connection in 10seconds interval because of huge number of clients , cost of transfer - clients use paid gprs connection. , in time client application has problem reconnection.

there other problem. when first connection form user ok , trying connect other application same name of user second connection has rejected.

if client attempts login username/password "connected", have 2 choices:

  1. reject new connection , keep using previous connection until disconnects (if times out, disconnect it).

  2. disconnect previous connection , use new connection.

whichever 1 decide use depends on particular needs.

you doing #1, sounds need use #2 instead. however, requirement "when first connection form user ok , trying connect other application same name of user second connection has rejected." requires #1 , prevents #2. kind of in catch-22 situation. there no way server know whether client abnormally disconnected on client end, has use keepalives/heartbeats detect that. cannot rely on server socket telling client dead in timely manner because has time out internally first, , can take long time without keepalives enabled.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -