what happens to the client side port/socket after server has disconnected and reconnected? -


my application talks pinpad device. pinpad acts server waiting clients connect. fire application, connects pinpad send command ack , things good.

now unplug ethernet cable pinpad, send command , after timeout application spits out error message saying 'device cannot reached/found'.

ok fine, plug cable pinpad , every time try send command pinpad same 'device cannot reached/found' message. have restart application , things good.

does mean original socket 2 parties using lost after unplug cable or port application talking on useless after unplugging cable? , need new port?

the 2 applications talking on tcp/ip.

you didn't transport protocol you're using.

if using tcp (stream socket), depends. if there no data transmission during interval in connectivity interrupted (the connection idle) , tcp keepalives not configured, there no effect: data transmitted after connectivity restored go through if there connectivity along. if, on other hand, data transmitted while connectivity broken, 1 of following things happen:

  • if connectivity interruption brief, data retransmitted after connectivity restored , connection recover normal state.
  • if connectivity interruption long, tcp stack on 1 or both ends declare timeout has occured. either etimedout error when happens or econnreset error after connectivity restored. in either case, socket not work again after event. if still want communicate, client have open new connection server.

if using udp (datagram socket), may errors , timeouts if transmit while connectivity interrupted, work again once connectivity restored. there no "memory".


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 -