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

  • SEARCH
  • Home
  • 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 3802548
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T14:13:33+00:00 2026-05-19T14:13:33+00:00

I am at a point in my Erlang development where I need to create

  • 0

I am at a point in my Erlang development where I need to create a C-Node (see link for C-Node docs). The basic implementation is simple enough, however, there is a huge hole in the doc.

The code implements a single threaded client and server. Ignoring the client for the moment… The ‘c’ code that implements the server is single threaded and can only connect to one erlang client at a time.

  1. Launch EPMD (‘epmd -daemons’)
  2. Launch the server application (‘cserver 1234’)
  3. Launch the erlang client application (‘erl -sname e1 -setcookie secretcookie’) [in a different window from #2]
  4. execute a server command (‘complex3:foo(3).’) from the erlang shell in #3

Now that the server is running and that a current erlang shell has connected to the server try it again from another window.

  1. open a new window.
  2. launch an erlang client (‘erl -sname e2 -setcookie secretcookie’).
  3. execute a new server command (‘complex3:foo(3).’).

Notice that the system seems hung… when it should have executed the command. The reason it is hung is because the other erlang node is connected and that there are no other threads listening for connections.

NOTE: there seems to be a bug in the connection handling. I added a timeout in the receive block and I caught some errant behavior but I did not get them all. Also, I was able to get the cserver to crash without warnings or errors if I forced the first erlang node to terminate after the indicated steps were performed.

So the question… What is the best way to implement a threaded C-Node? What is a reasonable number of connections?

  • 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-19T14:13:34+00:00Added an answer on May 19, 2026 at 2:13 pm

    The cnode implementation example in the cnode tutorial is not meant to handle more than one connected node, so the first symptom you’re experiencing is normal.

    The erl_accept call is what accepts incoming connections.

    if ((fd = erl_accept(listen, &conn)) == ERL_ERROR)
      erl_err_quit("erl_accept");
    fprintf(stderr, "Connected to %s\n\r", conn.nodename);
    while (loop) {
      got = erl_receive_msg(fd, buf, BUFSIZE, &emsg);
    

    Note that, written this way, the cnode will accept only one connection and then pass the descriptor to the read/write loop. That’s why when the erlang node closes, the cnode ends with an error, since erl_receive_msg will fail because fd will point to a closed socket.

    If you want to accept more than one inbound connection, you’ll have to loop accepting connections and implement a way to handle more than one file descriptor. You needn’t a multithread programme to do so, it would probably be easier (and maybe more efficient) to use the poll or select syscall if your OS supports them.

    As for the optimum number of connections, I don’t think there is a rule for that, you’d need to benchmark your application if you want to support high concurrency in the cnode. But in that case it would probably be better to re-engineer the system so that erlang copes with the concurrency, alleviating the cnode from that.

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

Sidebar

Related Questions

My point is this. For test i need when user check chk1 the chk2
A logical stuck point. I am building a simple ACL, and I am just
Is there a straightforward way to convert an Erlang fun to a string ?
I'm a beginner with rebar and erlang generally. I was trying to create an
The point of const-correctness is to be able to provide a view of an
Anyone point my at a utility for syncing sql server logins after restoring a
Could point me to some good links, or share experiences of the differences /
Kindly point towards theory/material to read for understanding colors and what makes a good
a point of architectural style that I'd like your opinion on please: My ORM
A point in 3-d is defined by (x,y,z). Distance d between any two points

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.