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 7885301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:01:38+00:00 2026-06-03T05:01:38+00:00

I am attempting to write a simple TCP server using Aleph. Everything works fine,

  • 0

I am attempting to write a simple TCP server using Aleph. Everything works fine, except I am unsure of how I should detect when a channel has been closed.

From the documentation:

When the client closes the connection, both sides of the channel will be immediately sealed. The final message from the channel will be nil

However, I never seem to receive this final nil message. If I inspect the channel, I do see that it has been closed. Here is my code:

(use 'lamina.core 'aleph.tcp 'gloss.core)

(defn process-msg [ch msg]
  (if (closed? ch)
    (println "Channel has been closed") ;This never happens
    (do-some-processing msg)))

(start-tcp-server
  (fn [ch client-info]
    (receive-all ch
      (partial process-msg ch))
  {:port 10000, :frame (string :utf-8 :delimiters ["\n"])})

Should I be doing something differently? Is my frame keeping the nil message from being processed? I could have a separate thread monitoring my channels and checking whether or not they have been closed, but this seems like a poor design. I would prefer to use Aleph, but right now its looking like I will need to use a raw Netty handler. Using Netty directly would be fine, but I’d prefer to use Aleph if possible since it feels a little more idiomatic.

  • 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-06-03T05:01:40+00:00Added an answer on June 3, 2026 at 5:01 am

    To register a callback for when a channel is closed or drained, use (on-closed ch callback) or (on-drained ch callback), which both take a callback with zero arguments.

    https://github.com/ztellman/lamina/wiki/Channels

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

Sidebar

Related Questions

I am attempting to write a simple game server for an Android game using
I'm writing a simple console client-server app using MSMQ. I'm attempting to run it
I'm attempting to write a simple buffer overflow using C on Mac OS X
I'm attempting to write a simple chat application in C using ncurses, both of
All, I'm attempting to write what should be simple validation for a Struts2 action.
I'm new to ANTLR, and I'm attempting to write a simple parser using C
I am attempting to write a value to the HKLM registry using TRegistry component
I'm attempting to write a simple query where I declare some variables and then
I am attempting to write a very simple rake task (and merge it into
I'm attempting to write a simple ScopeGuard based on Alexandrescu concepts but with c++11

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.