ssl - erlang socket send timeout never happens -


i implementing tcp server in erlang talks mobile phone clients. mobile phones offline lot, server must able detect it. hence want server send messages clients timeout, when timeout happens connection closed , client marked offline.

i used listen option on server:

[{certfile, "cert.pem"},     {keyfile, "key.pem"},  {reuseaddr, true},     {active, false},  {send_timeout, 10000}] 

after set connection between server , mobile phone, switch phone airplane mode(which shuts down wireless signals), , ssl:send on server. send function happliy returned ok if packet transmitted.

what have done wrong?

did set {send_timeout_close, true} parameter on socket inet? if not, socket won't closed, return timeout error. there risk ssl swallows error , it.

some other points:

  • remember check return value of ssl:send , ssl:receive options error. important know send went well.

    ok = ssl:send(sock, data), 
  • the underlying tcp/ip stack might accept data send_timeout set, won't able send other endpoint down. knowledge of closed port first arrives later on, when stack realizes never got ack.

  • there raw entry type sockets, defined in inet. allows set os-specific socket options. may possible coerce os being more aggressive @ detecting loss of connection.

  • another option cue on ssl:recv/3 call timeout signifies loss of device, regardless of socket status. has advantage of detecting application trouble in other end not progress along determined path. have processing further requests anyway.

  • the mobile phone client can act. if send's message on ssl , receive never arrives (due airplane mode) - knows wrong. server may not know however.

  • tcp/ip provides reliable, connection-oriented stream protocol. not guard against sudden disconnects. important protocol must handle disconnect problem itself. important if protocol has kind of confirmation or acknowledgement.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -