Solved

the exception of select()

Posted on 1997-05-25
3
258 Views
Last Modified: 2013-12-26
Dear Sirs:
   I use a SUN-OS4.1.3 and the client PC is Win95.
I use the select() function call with recv() and send()
there are all good. But when I use the exception of the
select() function to receive the out of band data from
the client PC, I use recv(__,__,MSG_OOB) to read out the
out of band data over, and then the exception still there.
I donot know why.
   My main question is:
    (1) How to clear the exception condition of select()
function, after read out the out of band data ?
    (2) I know the socket urgent data could use the signal
"SIGURG" and "SIGIO", but the exception of select() seems
the same or not ?

The Best Regards,
0
Comment
Question by:arthurjj
3 Comments
 
LVL 5

Accepted Solution

by:
julio011597 earned 50 total points
ID: 1293097
Hello arthurjj,

1) to clear the exception condition you will go as you probably do with read or write conditions: between select() calls, you should issue:

FD_CLR(file_descriptor, exception_set); /* which clears file_descriptor in exception_set */

or

FD_ZERO(exception_set) /* which clears the whole exception set */

2) SIGURG is raised when there's an urgent condition on a I/O channel (out-of-band data), while SIGIO is raised when _any_ kind of I/O is 'possible or completed';

SIGIO traps too many events to be useful for socket programming; SIGURG may be a way to know there's some oob data to read, but, unless your server application handles just one socket stream, you will still need to select();

so, in the end, select() remains the most common (maybe best general) way to check the state of one or more socket streams; you will usually go with signal handling just for a few particular tasks.

HTH, julio
0
 

Author Comment

by:arthurjj
ID: 1293098
Dear Sir:
   I received your answer about the exception of select() function. I tried it again, and found the result was the same
with before the exception still happened. My flow as following:
 In Sun Host:
  (0) Init all and listen.
  (1) Got a file description of socket connection--- fd1;
  (2) FD_ZERO(&fd_read); FD_ZERO(&fd_write); FD_ZERO(&fd_exc);
      FD_SET(fd1,&fd_read);FD_SET(fd1,&fd_write);
      FD_SET(fd1,&fd_exc);
  (3) ns=select(FD_SETSIZE,&fd_read,&fd_write,&fd_exc,&timeout);
  (4) if (ns==0) Goto Step (2);
      else if (ns<0) Goto Step_Error;
      else next;
  (5) if (FD_ISSET(fd1,&fd_read))  recv() all of input data;
  (6) if (FD_ISSET(fd1,&fd_write)) send() all of output data;
  (7) if (FD_ISSET(fd1,&fd_exc))   recv(,,MSG_OOB) all of
      out of band data. and use FD_CLR(fd1,&fd_exc);
  (8) Goto Step (2);
 
  While all the data and OOB data was read over. The IO buffer
  is empty. I use the ioctl(fd1,SIOCATMARK,&n1) to check it is
  really empty. The read and write flag were nothing but the
  exception flag( fd_exc) still exist.
  I do not know why ?
  Whould you solve this problem, please ?
  Thanks again !!!
  The Best Regards,
  Arthur Chang.
  arthurjj@ms5.hinet.net

 

 
       



0
 

Expert Comment

by:lemontel
ID: 7486536
The problem is that select indicates an exception condition until the process reads beyond the out-of-band data(pp.530-531 of TCPv2).
The solution is to select for an exception condition only after reading normal data.
  -- UNIX Network Programming, Vol1, W.Richard Stevens
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
mixString challenge 36 112
List out all word 7 261
centeredAverage challenge 8 132
wordcount challenge 11 110
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now