The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Special Forums > IP Networking
.
google unix.com



IP Networking Learn TCP/IP, Internet Protocol, Routing, Routers, Network protocols in this UNIX and Linux forum.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Script to number incoming files hootdocta5 Shell Programming and Scripting 5 03-19-2009 10:19 PM
Info req: /var/adm/messages - Kern.warning - different ID messages Petrucci SUN Solaris 1 12-04-2008 01:30 PM
run a script from incoming email jojo77 UNIX for Dummies Questions & Answers 7 02-22-2008 01:48 PM
Check incoming mail to sendmail kingdbag UNIX for Dummies Questions & Answers 1 01-25-2007 11:32 PM
rlogin/rsh incoming port andryk High Level Programming 1 08-17-2004 10:21 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-01-2009
charlitos charlitos is offline
Registered User
  
 

Join Date: Feb 2009
Posts: 1
Unhappy 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 (permalink)  
Old 04-14-2009
sneakyimp sneakyimp is offline
Registered User
  
 

Join Date: Apr 2009
Posts: 14
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.
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 04:36 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0