"select" in Racket - networking

I want to write an event loop single threaded web server to deal with each request in Racket.
I see there are select method in unix that I can call,
Is there anything similar in Racket API that I can call? or I should write my own select method which is to polling the ready fds?
Thanks in advance!

Apologies if I'm misunderstanding your question, but it sounds like you'll probably want to use tcp-listen on certain ports; success here will create input ports. In order to synchronize on multiple open input ports, check out "synchronizable events"; you can use 'sync' on a whole bunch of open ports simultaneously.
I would be remiss if I failed to add that there's a complete web server included with Racket; I'm assuming that you have your own reasons for wanting to re-implement this.

Related

variables in extensions_custom.conf

I am using Queues to handle incoming calls which works pretty well.
What I would like to do now is to get the info which extensions has answered a call in "sub-queue-answer" context of extensions_custom.conf to hand over this information via CURL to another - e.g. CRM-server via:
exten => s,n,Set(foo=${CURL(https://hostname/voipcr.php?device=pbx1.xxx\&agent=${???}...)})
anyone any idea which variable can be set in the spaceholder of the three ??? to hand over the extension number of the agent who has answered that call?
i usually use ${CUT(DIALEDPEERNUMBER,#,1)}
You can not do that using extensions. Queues are sending calls to users without passing through the dialplan (a queue will call a agent directly).
To access data about who answered the call (and also when that happened) you need to listen for the AgentConnect event on Asterisk Manager Interface. As you can see in the documentation, the AgentConnect event will pass a lot of properties that you can parse, to extract the information you need. Probably you want to check MemberName and Interface properties, but that is subject to your particular setup.
Queue logs / CDR will help you only if you want to send the data after the call has been completed, but, to do that, you probably need to create a pooling system (an undesirable solution, from my point of view).

Sharing data between PAM app and PAM module

I have a PAM application that makes use of a particular PAM module for authentication chores. My question is, what is the best for the module to share an arbitrary string of bytes with the application?
My understanding of the PAM API is that, in general, the application must use the pam_get_item() call in order to obtain data from the module. However, the item types that can be shared are very limited, and they do not seem to accommodate for what I need - with the possible exception of the PAM_CONV item type. If anybody in this forum has experience with this kind of thing their feedback would be much appreciated.
After some experimentation I think I found the answer. In essence, the application has to define a PAM conversation callback in which a pointer to a data buffer is provided. The PAM module has to invoke the callback at the appropriate time, and copy the appropriate data into that buffer. The application will simply obtain the desired data by reading the contents of the buffer.
This will of course have to be carefully choreographed by the application, and the module may have to be modified to invoke the callback at the right time. The idea is simple though.
I am learning a lot as a result of posting to this forum, even if I don't seem to be getting any feedback when it comes to PAM-related questions.
I think you can use PAM_CONV. as it says:
The PAM library uses an application-defined callback to allow a direct
communication between a loaded module and the application. This
callback is specified by the struct pam_conv passed to pam_start(3) at
the start of the transaction.

Uncommon? Call Forwarding Rule

I'm looking to have my FreePBX server forward incoming calls to a phone number that it pulls from a mysql database. The only thing unique about how I need it to forward calls is that there will be multiple numbers located in the database, and I need my PBX to choose one of these numbers purely at random and forward the call there. Is there a native function in FreePBX or Asterisk that allows for pulling a number at random from a database and forwarding the call there? Help is much appreciated
There are no module like that. You can write it or ask someone write it.
You also can use extension with type-> custom and dialline like s#special-dial. After that put in context special-dial into file extensions_custom.conf which will access database.
http://www.voip-info.org/wiki/view/Asterisk+config+extensions.conf
http://www.voip-info.org/wiki/view/Asterisk+func+func_odbc

Asynchronous Update in Web2py of a single instance

I am currently writing a program in web2py to control a dynamometer. It essentially mimics functionality provided by labview (ie. set the mode, direction, and speed/torque of dyno, query dyno speed). I want to be able to keep one instance of the dyno alive and update a print output of the value of the dyno's speed several times a seconds without having the user do anything. Is this possible and is there a way I can do this with scheduler or is there a better way I should go about doing it? Thanks in advance.
Yes, it is possible. You need to look into gluon/contrib/websocket_messaging.py. It contains an example in the docstring. You run it as a background process with Tornado and connect it to the instrument. It will push data to the page via a websocket and trigger execution of custom js.

Generating SNMP traps

I am trying to implement just half of the SNMP functionality. On certain events, I want to create trap corresponding to each event. I am using C and Linux.
What would be the simplest way to achieve this? Do I need to use any open source utilities?Some of the events that I want to notify are very specific to my application. How to go about implementing this case?
I am new to SNMP. I have couple of basic questions: How agent and manager figure about what property i.e. object is being referred to? Do they both parse the MIB? How is MIB shared between agent and manager?
The easiest way is to execute Net-SNMP executable called snmptrap,
http://www.net-snmp.org/tutorial/tutorial-5/commands/snmptrap.html
Of course, you can also link to its underlying library so as to call the C functions directly.
About your basic questions on SNMP, you should start from a book, such as Essential SNMP or Understanding SNMP MIBs.

Resources