Sponsored Content
Full Discussion: handling incoming messages
Special Forums IP Networking handling incoming messages Post 302307124 by sneakyimp on Tuesday 14th of April 2009 04:19:09 PM
Old 04-14-2009
I'm not exactly sure what your question is asking, but it sounds like you are wrestling with the fact that you need a loop to listen for client connections with select on your server but you also need to do useful work. Likewise, in your client, you might need to listen for user input but at the same time wait for responses from the server.

I don't know what language you are using, but I've done this in PHP which puts a thin wrapper around the socket-related system calls so they are pretty similar. You generally need to decide whether to make a select() call blocking or not. if it's not blocking, you might be spinning in your main loop, repeatedly calling select() with no result and yet still chewing up lots of CPU time.

You might decide on a timeout where select() blocks for 100 milliseconds or sobefore deciding that there's no data and continuing to execute other code. This tends to undermine the performance of your application because there might be things you should be going while your app is sleeping.

If that's what your question is about, you might want to check into making your application multi-threaded (or multiprocessing). This concept would apply to both server and client. You can keep your main thread working away on request and delegate I/O to a separate thread and let the operating system take care of all the scheduling. The I/O thread will queue up all the I/O requests and the main thread will dutifully service them, handing them back to the I/O thread when they are complete. Sadly, I am still looking into threading myself so I can't be of much further assistance. It can get a bit hairy when you deal with multithreading or multiprocessing because you have to watch out for things like race conditions, deadlock, and a host of other concurrency-related problems.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Check incoming mail to sendmail

I'm trying to find a command to check what mail is being sent to my sendmail server... Can't seem to find it... anyone know how to do this? (1 Reply)
Discussion started by: kingdbag
1 Replies

2. UNIX for Dummies Questions & Answers

run a script from incoming email

hi I have a bit of a problem i need help with. I have a script that runs no problems when i run it manually. as soon as i stick in tester: /app/scripts/run.pl into /etc/aliases & try to run it by sending a mail it doesnt work. the output files are owned by daemon, which i dont like & think... (7 Replies)
Discussion started by: jojo77
7 Replies

3. UNIX for Dummies Questions & Answers

how to automate incoming mail processing

Hi All, I require to develop some script which will continuously be looking for mails from some specific mail addresses on AIX server. Once any such mail arrives, the process will look into the mail subject and mail body to search for some keywords like success or failure, filename etc.... (3 Replies)
Discussion started by: vivek8220
3 Replies

4. Shell Programming and Scripting

Script to number incoming files

Hey guys, I am working on a Cshell script and I am stuck on this one part. I need to be able to copy in files to my directory but give them different names so they don't overwrite each other. For example, my folder already contains FILE.1 I want my script to name the next file copied over... (5 Replies)
Discussion started by: hootdocta5
5 Replies

5. Shell Programming and Scripting

Incoming mail Alert !!

Hi, If I am getting any new mail in my mail box I need an alet message . Please help me to get the script .. (1 Reply)
Discussion started by: pranabrana
1 Replies

6. UNIX for Dummies Questions & Answers

Help: script to monitor incoming files

I have 20 or so files that are ftp'd each day to a particular directory. I want to create a script that will tell me if any of these files fails to arrive or if any additional files arrive. I'm thinking I'd have a list of file names that should arrive each day, and the script would check each days... (2 Replies)
Discussion started by: daveyc82
2 Replies

7. Solaris

logging incoming connections on solaris 10

i've been able to log incoming telnet and ssh connections on solaris 9 using the following lines in /etc/syslog.conf # Telnet connections are logged to auth.notice auth.notice /var/adm/authlog # An entry in /etc/profile logs all telnet connections... (2 Replies)
Discussion started by: soliberus
2 Replies

8. Linux

incoming mails not coming

I am using Linux box. i am able to send mails through sendmail to local and other domains. i am not receving any incoming mails. dovecot service is running. (4 Replies)
Discussion started by: harishindn
4 Replies

9. Shell Programming and Scripting

Block all incoming connection for 10h

Hi all, I am working on a shell script that blocks all incoming and outgoing connections for 10 hours. After then hours everything will be unblocked again. i am using the ipfw command and put it to sleep the amount of time in seconds. ipfw -q flush ipfw -f add deny tcp from any to... (8 Replies)
Discussion started by: runtimeError
8 Replies

10. IP Networking

All incoming connections ips LOG

How to make a log that will log all ips that connect to the server or send packets? And how to block an ip that make packets flood and try to DDoS? Thanks. (1 Reply)
Discussion started by: [xEF]Danger
1 Replies
ivykis(3)						    ivykis programmer's manual							 ivykis(3)

NAME
ivykis - library for asynchronous I/O readiness notification DESCRIPTION
ivykis is a library for asynchronous I/O readiness notification. It is a thin, portable wrapper around OS-provided mechanisms such as epoll_create(2), kqueue(2), poll(2), poll(7d) (/dev/poll), port_create(3C) and select(2). ivykis was mainly designed for building high-performance network applications, but can be used in any event-driven application that uses poll(2)able file descriptors as its event sources. While some programming models dictate using blocking I/O and starting a thread per event source, programs written to the ivykis API are generally single-threaded (or use only a small number of threads), and never block on I/O. All input and output is done in a nonblocking fashion, with I/O readiness notifications delivered via callback functions. The two main event sources in ivykis are file descriptors and timers. File descriptors generate an event when they become readable or writable or trigger an error condition, while timers generate an event when the system time increments past a certain pre-set time. Events associated with file descriptors are level-triggered -- a callback function set up to handle a certain file descriptor event will be called repeatedly until the condition generating the event has been cleared. As mentioned, applications using ivykis are generally single-threaded. Event callbacks are strictly serialised within a thread, and non- preemptible. This mostly removes the need for locking of shared data, and generally simplifies writing applications. Each thread that uses ivykis has its own file descriptors and timers, and runs a separate event loop. In ivykis, all code that is not initialization code runs from callback functions. Callback functions are not allowed to block. If a par- ticular piece of code wants to perform a certain operation that can block, it either has to schedule it to run in a separate thread, or it has to perform the operation in a nonblocking fashion instead. For example, registering an input callback function instead of blocking on a read, registering a timer instead of calling sleep(2), etc. In case of an internal error, ivykis will use iv_fatal(3) to report the error. The application can provide a custom fatal error handler by calling iv_set_fatal_msg_handler(3). SEE ALSO
iv_examples(3), iv_fatal(3), iv_fd(3), iv_timer(3), iv_task(3), iv_init(3), iv_main(3), iv_time(3) ivykis 2010-08-15 ivykis(3)
All times are GMT -4. The time now is 10:10 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy