LinuxQuestions.org
Help answer threads with 0 replies.
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 10-03-2011, 09:28 AM   #16
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled

Try the following:
  1. Set newfd to O_NONBLOCK when the client connects.
  2. Temporarily comment out the continue after select.
  3. Write a temporary loop after select that tries to recv from every client using descr_list and not master. You might even skip select and do this every 10s or so.
This is to see if input is actually available when you're expecting it to be and to make sure you've recorded the descriptors correctly.

There is also a problem here, which probably doesn't cause what we're discussing:
Quote:
Originally Posted by errigour View Post
Code:
    	while(descr_list != NULL)
    	{
	    	r = descr_list->next;
    	    if(descr_list->state == SAY_GOODBY)
     		{
	         	close(descr_list->newfd);
	         	FD_CLR(descr_list->newfd, &master);
         		free(descr_list);
     		}
     		descr_list = r;
 		}
 		descr_list = keepsake;
When you free a client here you don't remove it from the linked list.
Kevin Barry
 
Old 10-05-2011, 06:36 PM   #17
errigour
Member
 
Registered: May 2009
Posts: 291

Original Poster
Rep: Reputation: 6
How do I use and send read_fds inside and to a function.
Is the following lagit?
Code:
set_fdset(fdset read_fds)
{
    FD_SET(newfd, &read_fds);
}
 
Old 10-05-2011, 10:04 PM   #18
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
Quote:
Originally Posted by errigour View Post
How do I use and send read_fds inside and to a function.
Is the following lagit?
Code:
set_fdset(fdset read_fds)
{
    FD_SET(newfd, &read_fds);
}
You should pass an fd_set* because it's a struct (in most, if not all cases.)
Kevin Barry
 
Old 10-07-2011, 10:10 AM   #19
errigour
Member
 
Registered: May 2009
Posts: 291

Original Poster
Rep: Reputation: 6
When I try to receive data thats not there after select
I get an error with recv
Code:
Receiving a file descriptor: Resource temporarily unavailable
 
Old 10-07-2011, 10:44 AM   #20
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
Quote:
Originally Posted by errigour View Post
When I try to receive data thats not there after select
I get an error with recv
Code:
Receiving a file descriptor: Resource temporarily unavailable
That's what should happen when the socket is non-blocking; this error corresponds to EAGAIN and EWOULDBLOCK. Did this come up as a result of my advice a few posts ago? If so, it just means that if FD_ISSET isn't returning "true" then that's probably because there isn't data to be read, which implies a problem with the client. This is basically what I was trying to find out when I gave those suggestions. On the other hand, you need to keep running the loop (maybe with a pause between iterations) to make sure you haven't checked for input too early.

Just to be clear, I'm having you temporarily replace select with a periodic non-blocking recv to see if at any point there's actually data to be read from the client's socket.
Kevin Barry
 
  


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
fprintf() before select() doesn't print anything exponential Programming 2 04-23-2007 02:05 PM
MySQL the syntax to SELECT doesn't work for DELETE Melsync Programming 2 03-31-2007 06:59 AM
DVD menu - doesn't work/can't select anything pingu Linux - Software 3 10-31-2005 10:33 AM
Using Select to make a simple directory menu why doesn't it work ctrimble Programming 5 06-07-2004 02:21 AM
Cut(Select) and Paste doesn't work! andykerouac Linux - General 0 02-11-2004 03:32 PM

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

All times are GMT -5. The time now is 01:04 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration