<?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 USING PSEUDO TERMINALS in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/using-pseudo-terminals/m-p/4316428#M683173</link>
    <description>Hi All,&lt;BR /&gt;&lt;BR /&gt;       I have a small requirement in one of our projects to read and write from pseudo terminals.&lt;BR /&gt;&lt;BR /&gt;         for this i have written 2 programs&lt;BR /&gt;     1) master.cpp &lt;BR /&gt;     2) slave.cpp&lt;BR /&gt;&lt;BR /&gt;       First master opens a pseudo terminal using the function openpty(); &lt;BR /&gt;        and uses select call to wait until data appears on the slave.&lt;BR /&gt;         Once we run slave program and enter something into the slave device, the same thing is read from master.&lt;BR /&gt;          And the master has to send some text to the slave.&lt;BR /&gt;&lt;BR /&gt;         I am able to write into slave and read from master. &lt;BR /&gt;          But, after reading in master i am not able to write back to slave.&lt;BR /&gt;&lt;BR /&gt;        I am attaching both my master.cpp and my slave.cpp is as below.&lt;BR /&gt;&lt;BR /&gt;        #include &lt;SYS&gt;&lt;BR /&gt;#include &lt;SYS&gt;&lt;BR /&gt;#include &lt;SYS&gt;&lt;BR /&gt;#include &lt;FCNTL.H&gt;&lt;BR /&gt;#include &lt;UNISTD.H&gt;&lt;BR /&gt;#include &lt;WAIT.H&gt;&lt;BR /&gt;&lt;BR /&gt;#include &lt;STDLIB.H&gt;&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;#include &lt;IOSTREAM&gt;&lt;BR /&gt;using namespace std;&lt;BR /&gt;#define SIZE 25&lt;BR /&gt;int main ()&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;  char buffer[205];&lt;BR /&gt;  int slavept;&lt;BR /&gt;  slavept=open("/dev/pts/6", O_RDWR|O_NOCTTY );  // Use the slave device opened by master.cpp &lt;BR /&gt;  fd_set readfd, errfd;&lt;BR /&gt;  int selret;&lt;BR /&gt;  struct timeval time;&lt;BR /&gt;&lt;BR /&gt;  //grantpt( slavept ) ;&lt;BR /&gt;  //unlockpt( slavept ); &lt;BR /&gt;  time.tv_sec = 2;&lt;BR /&gt;&lt;BR /&gt;    while (1)&lt;BR /&gt;    {&lt;BR /&gt;       //cout &amp;lt;&amp;lt;"ENTER WIZARD COMMAND ==&amp;gt;"&amp;lt;&amp;lt; endl;&lt;BR /&gt;       //cin &amp;gt;&amp;gt; buffer;&lt;BR /&gt;       int num=write(slavept,buffer,SIZE);&lt;BR /&gt;       //sleep(20);&lt;BR /&gt;&lt;BR /&gt;        FD_ZERO(&amp;amp;readfd);&lt;BR /&gt;        FD_SET(slavept, &amp;amp;readfd);&lt;BR /&gt;        //sleep (10); &lt;BR /&gt;         selret = select(slavept+1, &amp;amp;readfd, NULL, NULL, NULL);&lt;BR /&gt;        cout &amp;lt;&amp;lt; "SelRet =" &amp;lt;&amp;lt; selret &amp;lt;&amp;lt; endl;&lt;BR /&gt;&lt;BR /&gt;//&lt;BR /&gt;         if (selret &amp;gt; 0 ) &lt;BR /&gt;              {&lt;BR /&gt;         read( slavept, buffer, SIZE );&lt;BR /&gt;        cout &amp;lt;&amp;lt; "DATA FROM MASTER IS =&amp;gt;"&amp;lt;&lt;BUFFER&gt;&lt;/BUFFER&gt;        }&lt;BR /&gt;&lt;BR /&gt;       }&lt;BR /&gt;                close( slavept );&lt;BR /&gt;  return 0;&lt;BR /&gt; }&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;         Can any one have a look at it and please help me out to get rid of this blockage &lt;BR /&gt;  &lt;BR /&gt;Thanks in Advance&lt;BR /&gt;    Vikram&lt;BR /&gt;&lt;/IOSTREAM&gt;&lt;/STDIO.H&gt;&lt;/STDLIB.H&gt;&lt;/WAIT.H&gt;&lt;/UNISTD.H&gt;&lt;/FCNTL.H&gt;&lt;/SYS&gt;&lt;/SYS&gt;&lt;/SYS&gt;</description>
    <pubDate>Tue, 02 Dec 2008 12:11:08 GMT</pubDate>
    <dc:creator>CA1490051</dc:creator>
    <dc:date>2008-12-02T12:11:08Z</dc:date>
    <item>
      <title>USING PSEUDO TERMINALS</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/using-pseudo-terminals/m-p/4316428#M683173</link>
      <description>Hi All,&lt;BR /&gt;&lt;BR /&gt;       I have a small requirement in one of our projects to read and write from pseudo terminals.&lt;BR /&gt;&lt;BR /&gt;         for this i have written 2 programs&lt;BR /&gt;     1) master.cpp &lt;BR /&gt;     2) slave.cpp&lt;BR /&gt;&lt;BR /&gt;       First master opens a pseudo terminal using the function openpty(); &lt;BR /&gt;        and uses select call to wait until data appears on the slave.&lt;BR /&gt;         Once we run slave program and enter something into the slave device, the same thing is read from master.&lt;BR /&gt;          And the master has to send some text to the slave.&lt;BR /&gt;&lt;BR /&gt;         I am able to write into slave and read from master. &lt;BR /&gt;          But, after reading in master i am not able to write back to slave.&lt;BR /&gt;&lt;BR /&gt;        I am attaching both my master.cpp and my slave.cpp is as below.&lt;BR /&gt;&lt;BR /&gt;        #include &lt;SYS&gt;&lt;BR /&gt;#include &lt;SYS&gt;&lt;BR /&gt;#include &lt;SYS&gt;&lt;BR /&gt;#include &lt;FCNTL.H&gt;&lt;BR /&gt;#include &lt;UNISTD.H&gt;&lt;BR /&gt;#include &lt;WAIT.H&gt;&lt;BR /&gt;&lt;BR /&gt;#include &lt;STDLIB.H&gt;&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;#include &lt;IOSTREAM&gt;&lt;BR /&gt;using namespace std;&lt;BR /&gt;#define SIZE 25&lt;BR /&gt;int main ()&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;  char buffer[205];&lt;BR /&gt;  int slavept;&lt;BR /&gt;  slavept=open("/dev/pts/6", O_RDWR|O_NOCTTY );  // Use the slave device opened by master.cpp &lt;BR /&gt;  fd_set readfd, errfd;&lt;BR /&gt;  int selret;&lt;BR /&gt;  struct timeval time;&lt;BR /&gt;&lt;BR /&gt;  //grantpt( slavept ) ;&lt;BR /&gt;  //unlockpt( slavept ); &lt;BR /&gt;  time.tv_sec = 2;&lt;BR /&gt;&lt;BR /&gt;    while (1)&lt;BR /&gt;    {&lt;BR /&gt;       //cout &amp;lt;&amp;lt;"ENTER WIZARD COMMAND ==&amp;gt;"&amp;lt;&amp;lt; endl;&lt;BR /&gt;       //cin &amp;gt;&amp;gt; buffer;&lt;BR /&gt;       int num=write(slavept,buffer,SIZE);&lt;BR /&gt;       //sleep(20);&lt;BR /&gt;&lt;BR /&gt;        FD_ZERO(&amp;amp;readfd);&lt;BR /&gt;        FD_SET(slavept, &amp;amp;readfd);&lt;BR /&gt;        //sleep (10); &lt;BR /&gt;         selret = select(slavept+1, &amp;amp;readfd, NULL, NULL, NULL);&lt;BR /&gt;        cout &amp;lt;&amp;lt; "SelRet =" &amp;lt;&amp;lt; selret &amp;lt;&amp;lt; endl;&lt;BR /&gt;&lt;BR /&gt;//&lt;BR /&gt;         if (selret &amp;gt; 0 ) &lt;BR /&gt;              {&lt;BR /&gt;         read( slavept, buffer, SIZE );&lt;BR /&gt;        cout &amp;lt;&amp;lt; "DATA FROM MASTER IS =&amp;gt;"&amp;lt;&lt;BUFFER&gt;&lt;/BUFFER&gt;        }&lt;BR /&gt;&lt;BR /&gt;       }&lt;BR /&gt;                close( slavept );&lt;BR /&gt;  return 0;&lt;BR /&gt; }&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;         Can any one have a look at it and please help me out to get rid of this blockage &lt;BR /&gt;  &lt;BR /&gt;Thanks in Advance&lt;BR /&gt;    Vikram&lt;BR /&gt;&lt;/IOSTREAM&gt;&lt;/STDIO.H&gt;&lt;/STDLIB.H&gt;&lt;/WAIT.H&gt;&lt;/UNISTD.H&gt;&lt;/FCNTL.H&gt;&lt;/SYS&gt;&lt;/SYS&gt;&lt;/SYS&gt;</description>
      <pubDate>Tue, 02 Dec 2008 12:11:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/using-pseudo-terminals/m-p/4316428#M683173</guid>
      <dc:creator>CA1490051</dc:creator>
      <dc:date>2008-12-02T12:11:08Z</dc:date>
    </item>
  </channel>
</rss>

