From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,3c5dc1bbcd3bbc68,start X-Google-Attributes: gidfee84,public From: "Kim younghan" Subject: Help : Asynchronous programming Date: 1998/10/30 Message-ID: <71bjl1$qpj$1@news.HanQ.net>#1/1 X-Deja-AN: 406573521 Organization: HanQ X-Mimeole: Produced By Microsoft MimeOLE V4.72.3110.3 Newsgroups: comp.unix.osf.osf1 Hi Can anybody help me? Alpha would like to communicate with Tandem asynchronously via DECserver. Configuration is Alpha(Digital UNIX V4.0D) ----LAT----DECserver---Our DSU---9.6k----Their DSU-------Tandem Message foramt is STX(1) + message(98) + ETX(1) + BCC(1) Problem is Tandem can receive whole message from Alpha Alpha can not receive whole message except BCC. But we can get whole message at behind of Our DSU. If Tandem send message without ETX(0x03), Alpha can receive a whole message. Why? Here is a my source program. What's the problem? Please give me a good advice. Thanks in advance. mail to : yhkim@boram.co.kr ============================================================================ ====== #include #include #define BUFFSIZE 4096 int sigflag; typedef struct info_st { char stx; char kind[3]; char seqno[7]; char etx; char bcc; } INFO; INFO info; char inf[14]; main() { int fd,n,out; char buff[BUFFSIZE]; int sigio_func(); int cnt=0; info.stx = 0x02; info.etx = 0x03; info.bcc = 0; printf("... Before open \n"); if ((fd = open("/dev/tty03",O_RDWR)) == -1) { printf("... Can't open ttyq1 \n"); exit(1); } if ((out = open("bb",O_WRONLY|O_CREAT,0666)) == -1) { printf("... Can't open aa \n"); exit(1); } printf("... Open Successfully \n"); signal(SIGIO, sigio_func); if (fcntl(fd, F_SETFL, FASYNC) < 0) printf("F_SETFL FASYNC error \n"); /* if (fcntl(fd, F_SETFL, O_NDELAY) < 0) printf("F_SETFL O_NDELAY error \n"); */ sprintf(inf," %2s%6s ", "J2","000001"); inf[0] = 0x02; inf[9] = 0x03; inf[10] = 'A'; inf[11] = 0x0d; inf[12] = 0x0a; for(cnt=0;cnt<1;cnt++) { if (write(1, inf, 13) != 13) printf("Write error 1\n"); if (write(fd, inf, 13) != 13) printf("Write error 3\n"); printf("write ok!\n"); sleep(1); } write(out,inf,13); printf("now...receive...\n"); for ( ; ; ) { sigblock(sigmask(SIGIO)); while (sigflag == 0) sigpause(0); /* wait for a signal */ /* * We're here if (sigflag != 0). Also, we know that the * SIGIO signal is currently blocked. */ if (( n= read(fd, buff, BUFFSIZE)) > 0) { if (write(1, buff, n) != n) printf("Write error \n"); if (write(out, buff, n) != n) printf("Write error \n"); printf(".. Received length = %d \n",n); } else if (n < 0) printf(" Read error \n"); else if (n == 0) sigflag = 0; /* EOF */ /* exit(0); EOF */ /* sigflag = 0; turn off out flag */ sigsetmask(0); /* and reenable signals */ } } int sigio_func() { sigflag = 1; /* Just set flag and return */ /* the 4.3 BSD signal facilities leave this handler enabled for any further SIGIO signals */ } ============================================================================ ====== mail to : yhkim@boram.co.kr