From 4b561628b80579b9ef634c72a67166a35d1a8309 Mon Sep 17 00:00:00 2001 From: Rahul Paknikar Date: Tue, 25 Jun 2019 09:41:53 +0530 Subject: Multiple Outputs --- src/ghdlserver/ghdlserver.c | 108 +++++++++++++++++++++++++------------------- 1 file changed, 62 insertions(+), 46 deletions(-) diff --git a/src/ghdlserver/ghdlserver.c b/src/ghdlserver/ghdlserver.c index 09514e1..80b40f5 100644 --- a/src/ghdlserver/ghdlserver.c +++ b/src/ghdlserver/ghdlserver.c @@ -405,62 +405,78 @@ static void Data_Send(int sockid) out = calloc(1, 1024); - for (i=0;ikey) == 0) { found=1; - break; + // break; } - } - - if(found) - { - strncat(out, s->key, strlen(s->key)); - strncat(out, &colon, 1); - strncat(out, s->val, strlen(s->val)); - strncat(out, &semicolon, 1); + // } + + if(found) + { + strncat(out, s->key, strlen(s->key)); + strncat(out, &colon, 1); + strncat(out, s->val, strlen(s->val)); + strncat(out, &semicolon, 1); + printf("\n\n Out 1: %s \n\n", out); + } + else + { + printf("\n Failed (Not Found) at i=%d \n", i); + + syslog(LOG_ERR,"The %s's value not found in the table.", + Out_Port_Array[i]); + free(out); + return; + } + } + while(1) { - if (wrt_retries > 2) // 22.Feb.2017 - Kludge - { - free(out); - return; - } - ret = can_write_to_socket(sockid); - if (ret > 0) break; - if( ret == -100) - { - syslog(LOG_ERR,"Send aborted to CLT:%d buffer:%s ret=%d", - sockid, out,ret); - free(out); - return; - } - else // select() timed out. Retry.... - { - usleep(1000); - wrt_retries++; - } - } - } - else - { - syslog(LOG_ERR,"The %s's value not found in the table.", - Out_Port_Array[i]); - free(out); - return; - } - - if ((send(sockid, out, strlen(out), 0)) == -1) - { - syslog(LOG_ERR,"Failure sending to CLT:%d buffer:%s", sockid, out); - exit(1); - } + if (wrt_retries > 2) // 22.Feb.2017 - Kludge + { + free(out); + printf("\n Retries finished \n"); + return; + } + ret = can_write_to_socket(sockid); + if (ret > 0) break; + + if( ret == -100) + { + syslog(LOG_ERR,"Send aborted to CLT:%d buffer:%s ret=%d", + sockid, out,ret); + free(out); + printf("\n Cannot write Socket \n"); + return; + } + else // select() timed out. Retry.... + { + printf("\n Sleep \n"); + usleep(1000); + wrt_retries++; + } + } - syslog(LOG_INFO,"SNT:TRNUM:%d to CLT:%d buffer: %s", trnum++, sockid, out); - free(out); + if ((send(sockid, out, strlen(out), 0)) == -1) + { + printf("\n Failed (Socket not send) at i=%d \n", i); + syslog(LOG_ERR,"Failure sending to CLT:%d buffer:%s", sockid, out); + exit(1); + } + + syslog(LOG_INFO,"SNT:TRNUM:%d to CLT:%d buffer: %s", trnum++, sockid, out); + free(out); + } void Vhpi_Initialize(int sock_port) -- cgit