Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3484554
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:48:05+00:00 2026-05-18T10:48:05+00:00

I am implementing a TCP Server in Erlang which talks to mobile phone clients.

  • 0

I am implementing a TCP Server in Erlang which talks to mobile phone clients.
Mobile phones get offline a lot, so the server must be able to detect it.
Hence I want the server to send messages to clients with a timeout, so that when the timeout happens the connection is closed and the client are marked as offline.

I used this listen option on the server:

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

After I set up the connection between the server and the mobile phone, I switch the phone to airplane mode (which shuts down all wireless signals), and do an ssl:send on the server. The send function happliy returned ok as if the packet is successfully transmitted.

What have I done wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T10:48:06+00:00Added an answer on May 18, 2026 at 10:48 am

    Did you set the {send_timeout_close, true} parameter on the socket from inet? If not, the socket won’t be closed, just return back a timeout error. There is also the risk ssl swallows your error and does something with it.

    Some other points:

    • Remember to check the return value of any ssl:send and ssl:receive options for error. It is important to know that the send went well.

      ok = ssl:send(Sock, Data),
      
    • The underlying TCP/IP stack might actually accept the data even with a send_timeout set, but won’t be able to send it as the other endpoint is down. The knowledge of the closed port first arrives later on, when the stack realizes it never got an ACK.

    • There is a raw entry type for Sockets, defined in inet. It allows you to set OS-specific socket options. It may be possible to coerce the OS into being more aggressive at detecting the loss of a connection.

    • Another option is to cue everything on a ssl:recv/3 call where a timeout signifies loss of the device, regardless of its socket status. It has the advantage of also detecting application trouble in the other end as it does not progress along the determined path. You will have to do this for processing further requests anyway.

    • The mobile phone client can also act. If it send’s a message over SSL and the receive never arrives (due to airplane mode) – then it knows something is wrong. The server may not know this however.

    • TCP/IP provides a reliable, connection-oriented stream protocol. It does not guard against sudden disconnects. This is important as your protocol must handle the disconnect problem itself. It is especially important if your protocol has some kind of confirmation or acknowledgement.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm implementing a java TCP/IP Server using ServerSocket to accept messages from clients via
Hi I am implementing an IM-server-like application in Erlang. I used one agent process
I am implementing a server which accepts many concurrent connections. I used this structure:
I'm implementing a simple TCP client and TCP server in Java at the moment,
I implementing a EventQueue and get notified when AWTEvents are send. I wait till
I'm implementing a document server. Currently, if two users open the same document, then
I'm writing a TCP chat server ( programming language does not mather ). It's
I am looking for any strategies people use when implementing server applications that service
I have a java server that has to communicate over a TCP socket to
I have the following algorithm implemented in Java which uses TCP/IP: -Client request a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.