PLZ Help with guaranted UDP delivery

Discussion in 'C' started by raxbat, Jul 27, 2009.

  1. raxbat

    raxbat New Member

    Joined:
    Jul 27, 2009
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    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:
     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);
              si_other.sin_addr.s_addr=htonl(INADDR_ANY);
              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()");
     }
      close(s);
      return (0);
    }
     
    Last edited by a moderator: Jul 27, 2009

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice