<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: need help - poll() replaced with VMS services in Operating System - OpenVMS</title>
    <link>https://community.hpe.com/t5/operating-system-openvms/need-help-poll-replaced-with-vms-services/m-p/4783775#M41568</link>
    <description>Once more:&lt;BR /&gt;may be I'm not describe clearly the problem:&lt;BR /&gt;&lt;BR /&gt;I need a usual poll function with the one event additionally.&lt;BR /&gt;i.e.&lt;BR /&gt;I should wait for a sockets OR THE EVENT is set  for specefied timeout.&lt;BR /&gt;&lt;BR /&gt;It was very good, if anybody point me a good idea how to do it better or (the best) point me to OpenVMS poll sources.&lt;BR /&gt;</description>
    <pubDate>Thu, 05 May 2011 03:50:56 GMT</pubDate>
    <dc:creator>Alex Chupahin</dc:creator>
    <dc:date>2011-05-05T03:50:56Z</dc:date>
    <item>
      <title>need help - poll() replaced with VMS services</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/need-help-poll-replaced-with-vms-services/m-p/4783768#M41561</link>
      <description>&lt;!--!*#--&gt;hello dear all,&lt;BR /&gt;I'm working on replacing poll with VMS system service calls.&lt;BR /&gt;&lt;BR /&gt;This is the function for sockets.&lt;BR /&gt;input parameters: poll filled structure, an event flag for a something event, sometimes turned on anywhere, a buffer for the data read, and timeout.&lt;BR /&gt;&lt;BR /&gt;poll_with_event_with_read&lt;BR /&gt;is wait for a possible read from sockets, or event flag is set. When a socket become ready, it reads a data from it and store into buffer.&lt;BR /&gt;&lt;BR /&gt;First, I put my code,&lt;BR /&gt;Next message I describe every block if anybody does not like to grab this junk totally.&lt;BR /&gt;&lt;BR /&gt;This is my full code:&lt;BR /&gt;&lt;BR /&gt;int vms_poll_with_event_with_read(struct pollfd *poll_data, struct fd_buf *buf, int n, int timeout, unsigned event)&lt;BR /&gt;{&lt;BR /&gt;        char time_str[256];&lt;BR /&gt;        long long vmstimeout;&lt;BR /&gt;        unsigned long timer_efn;&lt;BR /&gt;        struct dsc$descriptor_s vmstime_str;&lt;BR /&gt;        struct dsc$descriptor_s vmsfd_name[n];&lt;BR /&gt;        unsigned status;&lt;BR /&gt;        unsigned efn[n];&lt;BR /&gt;        unsigned short chan[n];&lt;BR /&gt;        unsigned long long reqidt=0 /*=vaxc$get_sdc()*/;&lt;BR /&gt;        int ret=0;&lt;BR /&gt;        char fdname[256];&lt;BR /&gt;        int mask_flag=0;&lt;BR /&gt;        struct iosb    ios[n];&lt;BR /&gt;        int i;&lt;BR /&gt;&lt;BR /&gt;/* ---------block1 ---------*/&lt;BR /&gt;        status = LIB$GET_EF(&amp;amp;timer_efn);&lt;BR /&gt;&lt;BR /&gt;        if (n&amp;gt;0)&lt;BR /&gt;        {&lt;BR /&gt;                unsigned long long shift=1;&lt;BR /&gt;                for (i=0;i&lt;N&gt;&lt;/N&gt;                {&lt;BR /&gt;                        status = LIB$GET_EF(&amp;amp;efn[i]);&lt;BR /&gt;                        check(status);&lt;BR /&gt;                        /*&lt;BR /&gt;                        getname(poll_data[i].fd,fdname);&lt;BR /&gt;                        vmsfd_name[i].dsc$a_pointer = fdname;&lt;BR /&gt;                        vmsfd_name[i].dsc$w_length = strlen(fdname);&lt;BR /&gt;                        status = SYS$ASSIGN(&amp;amp;vmsfd_name[i],&amp;amp;chan[i],0,0,0);&lt;BR /&gt;                        check(status);&lt;BR /&gt;                        */&lt;BR /&gt;                        chan[i] = decc$get_sdc(poll_data[i].fd);&lt;BR /&gt;                        reqidt += chan[i]*shift;&lt;BR /&gt;                        shift *= 65535;&lt;BR /&gt;                }&lt;BR /&gt;        }&lt;BR /&gt;        else&lt;BR /&gt;        {&lt;BR /&gt;                reqidt=0;  /*timer id */&lt;BR /&gt;        }&lt;BR /&gt;&lt;BR /&gt;        if (timeout&amp;lt;0)&lt;BR /&gt;        {&lt;BR /&gt;                /* infinity timeout, do not set the timer */&lt;BR /&gt;                status=SYS$CLREF(timer_efn);&lt;BR /&gt;                check(status);&lt;BR /&gt;        }&lt;BR /&gt;        else&lt;BR /&gt;        {&lt;BR /&gt;                /* setting the timer, flag is timer_efn */&lt;BR /&gt;                sprintf(time_str,"0 00:%2d:%2d.00",(int)timeout/60,timeout%60);&lt;BR /&gt;                vmstime_str.dsc$w_length = strlen(time_str);&lt;BR /&gt;                vmstime_str.dsc$a_pointer = time_str;&lt;BR /&gt;                status = SYS$BINTIM (&amp;amp;vmstime_str, &amp;amp;vmstimeout);&lt;BR /&gt;                check(status);&lt;BR /&gt;                status = SYS$SETIMR (timer_efn, &amp;amp;vmstimeout, timer_ast, reqidt);&lt;BR /&gt;                check(status);&lt;BR /&gt;        }&lt;BR /&gt;&lt;BR /&gt;/*-----------block2 ----------*/&lt;BR /&gt;        if (n==0)&lt;BR /&gt;        {&lt;BR /&gt;                mask_flag=0;&lt;BR /&gt;                if (event&amp;gt;0)&lt;BR /&gt;                        mask_flag|=1&amp;lt;&amp;lt;(event-32);&lt;BR /&gt;                if (timer_efn&amp;gt;0)&lt;BR /&gt;                        mask_flag|=1&amp;lt;&amp;lt;(timer_efn-32);&lt;BR /&gt;                status = SYS$WFLOR(timer_efn,mask_flag); // wait for event or timer_efn&lt;BR /&gt;                check(status);&lt;BR /&gt;                status = SYS$READEF(timer_efn,&amp;amp;mask_flag);&lt;BR /&gt;                check(status);&lt;BR /&gt;&lt;BR /&gt;                status = LIB$FREE_EF(&amp;amp;timer_efn);&lt;BR /&gt;                return (mask_flag &amp;amp; (1&amp;lt;&amp;lt;(event-32)) ) ? 1 : 0;&lt;BR /&gt;        }&lt;BR /&gt;/* --------- block 3 -------- */&lt;BR /&gt;        mask_flag=0;&lt;BR /&gt;        for (i=0; i&lt;N&gt;&lt;/N&gt;        {&lt;BR /&gt;                if (!buf-&amp;gt;buffer)&lt;BR /&gt;                {&lt;BR /&gt;                        unsigned dummy;&lt;BR /&gt;                                status=SYS$QIO(efn[i],chan[i],IO$_READVBLK,&amp;amp;ios[i], qio_ast, &amp;amp;reqidt, &amp;amp;dummy, 1, 0,TCPIP$C_MSG_PEEK,&lt;BR /&gt;0,0);&lt;BR /&gt;                                                        }&lt;BR /&gt;                        ret=1;&lt;BR /&gt;                }&lt;BR /&gt;/* ---- block 4 ----- */&lt;BR /&gt;                else&lt;BR /&gt;                {&lt;BR /&gt;                                status=SYS$QIO(efn[i],chan[i],IO$_READVBLK,&amp;amp;ios[i], qio_ast, &amp;amp;reqidt,&lt;BR /&gt;                                        buf[i].buffer + buf[i].off, buf[i].bufsize - buf[i].off, 0,0,0,0);&lt;BR /&gt;                                                               }&lt;BR /&gt;                if (!(status &amp;amp; STS$M_SUCCESS))&lt;BR /&gt;                {&lt;BR /&gt;                        printf("Error CHAPG\n");&lt;BR /&gt;                }&lt;BR /&gt;&lt;BR /&gt;                mask_flag |= 1&amp;lt;&amp;lt;(efn[i]-32);&lt;BR /&gt;        }&lt;BR /&gt;        if (event&amp;gt;0)&lt;BR /&gt;                mask_flag |= 1&amp;lt;&amp;lt;(event-32);&lt;BR /&gt;        if (timer_efn&amp;gt;0)&lt;BR /&gt;                mask_flag |= 1&amp;lt;&amp;lt;(timer_efn-32);&lt;BR /&gt;/* ----- block 5 ----- */&lt;BR /&gt;        SYS$WFLOR(timer_efn,mask_flag); // wait for efn[0..n] or timer_efn or event);&lt;BR /&gt;        SYS$READEF(timer_efn,&amp;amp;mask_flag); //read flags status&lt;BR /&gt;        /* delete unready I/O queries */&lt;BR /&gt;        for (i=0; i&lt;N&gt;&lt;/N&gt;                SYS$CANCEL(chan[i]);&lt;BR /&gt;        SYS$CANTIM(reqidt,0); // Cancel timer&lt;BR /&gt;        status = LIB$FREE_EF(&amp;amp;timer_efn);&lt;BR /&gt;        for (i=0; i&lt;N&gt;&lt;/N&gt;        {&lt;BR /&gt;                if ( mask_flag &amp;amp; (1&amp;lt;&amp;lt;(efn[i]-32)) )&lt;BR /&gt;                {&lt;BR /&gt;                        status=ios[i].status;&lt;BR /&gt;                        buf[i].got_newdata=1;&lt;BR /&gt;                        if ( !(status &amp;amp; STS$M_SUCCESS) )&lt;BR /&gt;                     {&lt;BR /&gt;                                int ret;&lt;BR /&gt;This is may be wrong correspond to listen only socket buf[i].buffer==NULL*/&lt;BR /&gt;                                poll_data[i].revents=POLLHUP;&lt;BR /&gt;                        //      ret = send(poll_data[i].fd, &amp;amp;n, 0, 0);&lt;BR /&gt;                        //      if (!ret || (ret == -1 &amp;amp;&amp;amp; errno == EINTR))&lt;BR /&gt;                        //              poll_data[i].revents &amp;amp;= ~POLLHUP;&lt;BR /&gt;                        }&lt;BR /&gt;                        else&lt;BR /&gt;                        {&lt;BR /&gt;                                buf[i].off += ios[i].count;&lt;BR /&gt;                                poll_data[i].revents=POLLIN;&lt;BR /&gt;                                ret++;&lt;BR /&gt;                        }&lt;BR /&gt;                        printf("CHAPG %d\n",ios[i].count);&lt;BR /&gt;&lt;BR /&gt;                }&lt;BR /&gt;                else&lt;BR /&gt;                {&lt;BR /&gt;                        poll_data[i].revents=0;&lt;BR /&gt;                }&lt;BR /&gt;                status=LIB$FREE_EF(&amp;amp;efn[i]);&lt;BR /&gt;                //check(status);&lt;BR /&gt;        }&lt;BR /&gt;&lt;BR /&gt;        status = LIB$FREE_EF(&amp;amp;timer_efn);&lt;BR /&gt;&lt;BR /&gt;        if (ret==0)&lt;BR /&gt;                ret=1; /*it is mean only event flag is set*/&lt;BR /&gt;&lt;BR /&gt;        return ret;&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 03 May 2011 13:29:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/need-help-poll-replaced-with-vms-services/m-p/4783768#M41561</guid>
      <dc:creator>Alex Chupahin</dc:creator>
      <dc:date>2011-05-03T13:29:42Z</dc:date>
    </item>
    <item>
      <title>Re: need help - poll() replaced with VMS services</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/need-help-poll-replaced-with-vms-services/m-p/4783769#M41562</link>
      <description>ok.&lt;BR /&gt;&lt;BR /&gt;block 1.&lt;BR /&gt;I prepeared a timer with id composed from channel number. When timer is gone, ast timer routine will get this id, decode it and cancel all QIO requests passed to the channels.&lt;BR /&gt;&lt;BR /&gt;block 2.&lt;BR /&gt;it is executed when no sockets passed to the routine. So no QIOs, only wait for a timer or the event flag.&lt;BR /&gt;&lt;BR /&gt;For each passed socket:&lt;BR /&gt;block 3.&lt;BR /&gt;You may not look for it - it is requirement for the main software module - if buffer is NULL - it should do the "virtual" reading.&lt;BR /&gt;Do not know exactly what does it mean and what the conclusion.&lt;BR /&gt;block4&lt;BR /&gt;Executes real QIO. Flag efn[i] should be set when a QIO is completed.&lt;BR /&gt;ast routine cancels all QIOs for other channels that may be in queues or executed.&lt;BR /&gt;&lt;BR /&gt;block5.&lt;BR /&gt;waiting for any QIO flag, timer and event is set.&lt;BR /&gt;Then read flag event claster, checking for flags set, filling out poll structure.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 03 May 2011 13:43:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/need-help-poll-replaced-with-vms-services/m-p/4783769#M41562</guid>
      <dc:creator>Alex Chupahin</dc:creator>
      <dc:date>2011-05-03T13:43:42Z</dc:date>
    </item>
    <item>
      <title>Re: need help - poll() replaced with VMS services</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/need-help-poll-replaced-with-vms-services/m-p/4783770#M41563</link>
      <description>SAnd this is a question.&lt;BR /&gt;&lt;BR /&gt;This code is worked. Sometimes.&lt;BR /&gt;Sometimes not. &lt;BR /&gt;network server (this is a part of tcp server)&lt;BR /&gt;lost connection. It is depends from a CPU speed of machine code executed and Australia's weather.&lt;BR /&gt;I just see a bad places - the time from the event "QIO query is completed" and executing "cancel other QIOs" not equal to 0. So it is a chance that another QIO for another channel is completed before first ast procedure from first QIO delete all another QIOs.&lt;BR /&gt;&lt;BR /&gt;So I'll be very happy to see OpenVMS Master's examples how to work with threaded and timed QIO operations.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 03 May 2011 13:51:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/need-help-poll-replaced-with-vms-services/m-p/4783770#M41563</guid>
      <dc:creator>Alex Chupahin</dc:creator>
      <dc:date>2011-05-03T13:51:25Z</dc:date>
    </item>
    <item>
      <title>Re: need help - poll() replaced with VMS services</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/need-help-poll-replaced-with-vms-services/m-p/4783771#M41564</link>
      <description>And this code is not *in prodaction* of course, it is only for demostrate the problem.&lt;BR /&gt;</description>
      <pubDate>Tue, 03 May 2011 13:56:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/need-help-poll-replaced-with-vms-services/m-p/4783771#M41564</guid>
      <dc:creator>Alex Chupahin</dc:creator>
      <dc:date>2011-05-03T13:56:14Z</dc:date>
    </item>
    <item>
      <title>Re: need help - poll() replaced with VMS services</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/need-help-poll-replaced-with-vms-services/m-p/4783772#M41565</link>
      <description>May be somebody has a better solution/idea?&lt;BR /&gt;It should be very very good if any.&lt;BR /&gt;</description>
      <pubDate>Wed, 04 May 2011 10:08:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/need-help-poll-replaced-with-vms-services/m-p/4783772#M41565</guid>
      <dc:creator>Alex Chupahin</dc:creator>
      <dc:date>2011-05-04T10:08:34Z</dc:date>
    </item>
    <item>
      <title>Re: need help - poll() replaced with VMS services</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/need-help-poll-replaced-with-vms-services/m-p/4783773#M41566</link>
      <description>Are you aware that poll() has been available in the CRTL since 7.3-2?&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 04 May 2011 18:31:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/need-help-poll-replaced-with-vms-services/m-p/4783773#M41566</guid>
      <dc:creator>Craig A Berry</dc:creator>
      <dc:date>2011-05-04T18:31:37Z</dc:date>
    </item>
    <item>
      <title>Re: need help - poll() replaced with VMS services</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/need-help-poll-replaced-with-vms-services/m-p/4783774#M41567</link>
      <description>Yes, of course.&lt;BR /&gt;&lt;BR /&gt;But if you had read my first message you can see:&lt;BR /&gt;1. poll is available nothing exclude sockets.&lt;BR /&gt;2. Originally (software I'm porting) poll was used for mixed sockets and pipe as signaled tech. &lt;BR /&gt;3. If you see, the routine is named as *poll with event*. So any POLL events behavour should be mixed with an event.&lt;BR /&gt;&lt;BR /&gt;If you can easy mix poll integrated timeout with event please welcome.&lt;BR /&gt;Thats topic is devoted to.&lt;BR /&gt;</description>
      <pubDate>Thu, 05 May 2011 03:43:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/need-help-poll-replaced-with-vms-services/m-p/4783774#M41567</guid>
      <dc:creator>Alex Chupahin</dc:creator>
      <dc:date>2011-05-05T03:43:08Z</dc:date>
    </item>
    <item>
      <title>Re: need help - poll() replaced with VMS services</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/need-help-poll-replaced-with-vms-services/m-p/4783775#M41568</link>
      <description>Once more:&lt;BR /&gt;may be I'm not describe clearly the problem:&lt;BR /&gt;&lt;BR /&gt;I need a usual poll function with the one event additionally.&lt;BR /&gt;i.e.&lt;BR /&gt;I should wait for a sockets OR THE EVENT is set  for specefied timeout.&lt;BR /&gt;&lt;BR /&gt;It was very good, if anybody point me a good idea how to do it better or (the best) point me to OpenVMS poll sources.&lt;BR /&gt;</description>
      <pubDate>Thu, 05 May 2011 03:50:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/need-help-poll-replaced-with-vms-services/m-p/4783775#M41568</guid>
      <dc:creator>Alex Chupahin</dc:creator>
      <dc:date>2011-05-05T03:50:56Z</dc:date>
    </item>
    <item>
      <title>Re: need help - poll() replaced with VMS services</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/need-help-poll-replaced-with-vms-services/m-p/4783776#M41569</link>
      <description>If the "pipe" is a mailbox then here's an outline for a possible way to write your routine:&lt;BR /&gt;&lt;BR /&gt;Determine if the channel is a socket or mailbox&lt;BR /&gt;for socket queue a readattn ast &lt;BR /&gt;&lt;A href="http://www.openvms.compaq.com/doc/82final/6529/6529pro_026.html#readattn" target="_blank"&gt;http://www.openvms.compaq.com/doc/82final/6529/6529pro_026.html#readattn&lt;/A&gt;&lt;BR /&gt;For a mailbox queue set a read attention ast&lt;BR /&gt;&lt;A href="ftp://ftp.hp.com/pub/openvms/doc/AA-PV6SG-TK.PDF" target="_blank"&gt;ftp://ftp.hp.com/pub/openvms/doc/AA-PV6SG-TK.PDF&lt;/A&gt; look in the mailbox driver section for the mailbox function codes.&lt;BR /&gt;&lt;BR /&gt;queue timeout ast&lt;BR /&gt;wait for event flag(s)&lt;BR /&gt;the Ast(s) set event flags &lt;BR /&gt;poll event flags&lt;BR /&gt;&lt;BR /&gt;I haven't done a poll routine, but I've written routines that allowed a select-like function to be done for a combination of sockets, pipes and terminals (slightly more challenging than mailboxes), so this can be done.</description>
      <pubDate>Fri, 06 May 2011 14:54:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/need-help-poll-replaced-with-vms-services/m-p/4783776#M41569</guid>
      <dc:creator>Richard Whalen</dc:creator>
      <dc:date>2011-05-06T14:54:27Z</dc:date>
    </item>
  </channel>
</rss>

