handling incoming messages


 
Thread Tools Search this Thread
Special Forums IP Networking handling incoming messages
# 1  
Old 04-01-2009
Data handling incoming messages

I have a few clients connecting to the server(which is using select()) and theyre trying to send messages to each other. How do I wait for input on stdin and at the same time I wait for data to being sent from the server? Should I use select() in my client too? How exactly though?
# 2  
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
Login or Register to Ask a Question