Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   PLZ Help with guaranted UDP delivery (http://www.go4expert.com/forums/plz-help-guaranted-udp-delivery-t18713/)

raxbat 27Jul2009 16:54

PLZ Help with guaranted UDP delivery
Hello all! I have source code which deliveres UDP packets to server. Sometimes there is no internet connection for some time on server pc, so I need to modify my source code of server to collect buffer of UDP packets, before sending. All packets should be delivered to client. I suppose client have to send to server ACK messages if packet is delivered. If so, server should delete message from its own buffer. Please help me modify my code. Thanx
Code: C++

int main(void)
  int fd, n,j,i,zin_buf,ObjKods, SignLevel,cnt,nState,nReadCount;
  unsigned char buf[255];
  unsigned char msg[100];
  FILE * pFile;
  unsigned char bCRC[2];
  unsigned int nCrc;
       struct sockaddr_in si_other;
       int s, slen=sizeof(si_other);
       char buff[512];
  char my_array[100];
       int nr1;
          if ((s=socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP))==-1) diep("socket");
          memset((char *) &si_other, 0, sizeof(si_other));
          si_other.sin_family = AF_INET;
          si_other.sin_port = htons(UDPPORT);
          if (inet_aton(SRV_IP, &si_other.sin_addr)==0) { fprintf(stderr, "inet_aton() failed\n"); }           
          if ((s1=socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP))==-1) diep("socket");

 while (1==1) {     
                /*read info from com port
  if (sendto(s, my_array[i],512, 0, &si_other, slen)==-1) diep("sendto()");
  return (0);

All times are GMT +5.5. The time now is 21:04.