LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-08-2004, 06:26 AM   #1
jhon
Member
 
Registered: Aug 2004
Posts: 32

Rep: Reputation: 15
select - a misunderstanding


Hi,
I built a client server application (the first time):
TCP
client and server UNBLOCKING.

the application that I built was an indipendent project, and works just fine.

I now need to integrate it in my original workspace, in which computer A sends data for computer B that processes it and replies (big surprise)!!!

thus, I need to combine the client server code in the main loops of computes A, B.

Q1) how should I combine the server code in comp A, without causing the select() to block the application, as I need the server to do other things when no clients available?

Q1.1) should I solve the problem by creating a new thread that contains elect()? so it will not block computer A regular operation?

Q1.2) any other solutions?

Q2) just to understand the basic operation mechanism - when a client and server cooperate - are there different channels/ buffers from which client and server read/write data? i.e. does server have a buffer from which it is reading data and other one to which it is writing it? no chance for confusion?

thanks for your help
 
Old 09-08-2004, 07:27 AM   #2
Tigrebianca
LQ Newbie
 
Registered: Sep 2004
Posts: 4

Rep: Reputation: 0
Select() has a timeout parameter. Simply set it to zero so the FD_SET will be properly set only if datas are available at the moment of the call. Otherwise the call will end and the sets will be empty.
 
Old 09-08-2004, 11:57 AM   #3
chort
Senior Member
 
Registered: Jul 2003
Location: Silicon Valley, USA
Distribution: OpenBSD 4.6, OS X 10.6.2, CentOS 4 & 5
Posts: 3,660

Rep: Reputation: 76
Although this is about TCP/IP, it's really more of a programming question. Off to Linux - Programming!
 
Old 09-08-2004, 12:04 PM   #4
itsme86
Senior Member
 
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 59
Tigrebianca has suggested the best answer I can think of.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
select jhon Programming 5 11-01-2005 09:46 PM
Select() did not select my socket thvo Programming 1 05-08-2005 12:20 AM
Mysql SELECT WHERE LIKE ivanatora Linux - Software 3 03-20-2005 11:43 AM
what os to select kevinasr Linux - Newbie 2 05-18-2003 06:52 AM
How to select 3 OS in lilo ? pixelV Linux - General 1 12-26-2002 02:12 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:41 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration