delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/06/25/05:41:23

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-ID: <006a01c45a98$7cdb4450$b90d72d9@lsp>
From: "Lev Pliner" <pliner AT sky DOT ru>
To: "Lev Pliner" <pliner AT sky DOT ru>, <cygwin AT cygwin DOT com>
References: <001301c45a98$089c0cf0$b90d72d9 AT lsp>
Subject: Re: Question about select function [code of probe.c]
Date: Fri, 25 Jun 2004 15:40:44 +0600
MIME-Version: 1.0
X-IsSubscribed: yes

#include <stdio.h>
#include <sys/errno.h>
#include <rpc/rpc.h>

void
probe ( rqstp, transp )
    struct svc_req *rqstp;
    SVCXPRT *transp;
{
  switch ( rqstp->rq_proc )
  {
    case NULLPROC:
      svc_sendreply ( transp, xdr_void, (void *)NULL );
    return;
    default:
      svcerr_noproc ( transp );
    return;
  };
};

int
main ( argc, argv )
  int argc;
  char *argv[];
{
  SVCXPRT *transp = NULL;
  fd_set readfds;
  int size = getdtablesize ( );

  if ( ( transp = svctcp_create ( RPC_ANYSOCK, 0, 0 ) ) == NULL )
  {
    perror ( "1" );
    exit ( 1 );
  };

  svc_unregister ( 0x2A000001, 1 );

  if ( !svc_register ( transp, 0x2A000001, 1, probe, IPPROTO_TCP ) )
  {
    perror ( "2" );
    exit ( 1 );
  };

  if ( argc > 1 ) while ( 1 )
  {
    readfds = svc_fdset;

    switch ( select ( size, &readfds, NULL, NULL, NULL ) )
    {
      case -1:
        if ( errno == EINTR )
          continue;
        else
        {
          perror ( "3" );
          exit ( 1 );
        };
      break;
      case 0:
        continue;
      break;
      default:
        if ( !bcmp ( &readfds, &svc_fdset, sizeof ( fd_set ) ) )
          continue;
        svc_getreqset ( transp );
      break;
    };
  }
  else
    svc_run ( );

  exit ( 0 );
};


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019