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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:42:34+00:00 2026-05-13T17:42:34+00:00

A little background: I’ve written a script that will act as a receiver for

  • 0

A little background:

I’ve written a script that will act as a receiver for incoming Syslog/Email/Snmp(v1) traps. It receives the data and stores it as a custom defined object. My “messageSocket” is a means to control the behavior from a script outside of this general listener. I want to send messages to this to either start/stop on command. The start / stop essentially just change the state of the @running variable.

All of this works fine, except when I stop – if I trigger an event that creates an e-mail/trap etc it won’t be registered while @running = false. However, as soon as I set @running = true it will still see this socket data and analyze it.

I tried removing the given socket from my @descriptors array, I tried closing sockets, I tried setting res to different values. I’m guessing I’m just missing something at this point, any assistance or guidance would be greatly appreciated!

def run()  
   while 1 == 1

     res = select(@descriptors, nil, nil, nil)

     if res != nil then

        for sock in res[0]
          if sock == @mailSocket && @running == true then
            accept_new_connection
          elsif sock == @sysSocket && @running == true then
            get_syslog_message
          elsif sock == @snmpSocket && @running == true then
            get_snmp_message
          elsif sock == @mailSocket && @running == false then
            reject_mail
          elsif sock == @messageSocket then
            get_message()
          elsif sock == @snmpSocket && @running == false then
            #do something
          elsif sock == @sysSocket && @running == false then
            #do something
          end
        end   
      end
    end
 end
   #run end 
  end
  • 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-13T17:42:34+00:00Added an answer on May 13, 2026 at 5:42 pm

    If I recall, select is (sort of) level driven, not edge driven. In other words, if select returns descriptors and you do nothing with those descriptors, the next time you call select it will tell you again.

    So, if you are not running, you still have to read the data (or whatever else is appropriate for the event), or select will just tell you again later.

    To confirm my hypothesis, print “foo” right after the call to select, make @running be false and then try to establish a connection. If you see “foo” scolling by over and over, showing that select is not blocking, then I’m right. If you don’t, I’ll eat my words/delete my answer.

    As an aside, you can (and should) simply say @running instead of @running == true, and !@running instead of @running == false

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

Sidebar

Related Questions

For a little background, I work for a firm that develops web-based enterprise social
A little background: I'm creating a set of adapters to allow communication with mobile
First, a little background: I'm displaying a data set with 288 rows and 8
Background: I have a little video playing app with a UI inspired by the
We are developing a little application that given a directory with PDF files creates
My little site should be pooling list of items from a table using the
A little while ago I managed to get Visual Studio 2008 (C++) into a
A little example TTest<T> = class private f : T; public function ToString :
A little help needed. I'm receiving an xml file similar to this: <?xml version=1.0
My little brother is just getting into programming, and for his Science Fair project,

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.