Re: problem in select

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, May 17, 2006 at 09:59:38PM -0700, vikram b wrote:
> Hi All,
>           I dont know whether this is right place to put this ( Pls suggest if
> anybody know correct place)
> I am trying to use select system call to read from network socket. I have
> opened a socket and bind it on a port
> I have two threads (user space) each having a select , who is waiting on same
> Socket FD.
> When i send any data , only one of the thread is getting the data ...
> Is it normal ? Can i have any ways to have data to both select ?
> 
> Any suggestion will be of great help
> 
> 
> thanks in advance
> 
> vikram
> 
Hi,

yes, it's normal. It's not the goal of select.

In fact, in your case, what you do is just reading from the socket in a
thread. The data is taken from the socket. Then the other do another
read and there's no data.

If you want the data to be received by the two processes, you should
share it (threads have the same adress space, it's easy to do without
any mechanism).

In your case, if 2 threads want the data received (let's say thread A
and thread B), you should do 3 threads :
the first thread which just reads from the socket. When data is
received, it wakes up threads A and B.


-- 
tyler
tyler@xxxxxxxx


	

	
		
___________________________________________________________________________ 
Faites de Yahoo! votre page d'accueil sur le web pour retrouver directement vos services préférés : vérifiez vos nouveaux mails, lancez vos recherches et suivez l'actualité en temps réel. 
Rendez-vous sur http://fr.yahoo.com/set


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux