C sendto works sometimes…just stops after some time… NO ERRORS

This is a discussion on C sendto works sometimes…just stops after some time… NO ERRORS within the Networking/Device Communication forums, part of the General Programming Boards category; Hey, Ive been getting strange results with the sendto function in C.(LINUX) What I am trying to do is to ...

  1. #1
    Registered User
    Join Date
    Mar 2011
    Posts
    1

    C sendto works sometimes…just stops after some time… NO ERRORS

    Hey,

    Ive been getting strange results with the sendto function in C.(LINUX) What I am trying to do is to implement a reliable UDP kind of scheme.

    The snippet of code provided below is a part of the timer that expires when a packet is dropped and sends a message to a process to retransmit that packet.

    The weird problem which I am having is that when transferring a large file say... >300KB The code given below works perfectly (i.e. THE ELSE PART IS EXECUTED) But after a certain number of packets are sent...it executes the then part.!!!

    THIS IS STRANGE BECAUSE THE CODE WORKED FINE FOR ABOUT 250 PACKETS BUT WITH THE 251 PACKET kabooom!!!

    n = sendto(sockfd, &(forwardPeer->id), sizeof(forwardPeer->id), 0, (struct sockaddr*)&tcpd_addr, sizeof(tcpd_addr));
    if(n<0)
    printf("\n error sending to tcpdc");
    else
    printf("\n message sent to tcpdc");

    I tried with strerror and got an error number of 134514723
    Perror gives Unknown File descriptor

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,848
    Print the value stored in sockfd (that is, print it in the error message)
    Is it a garbage value, or good?

    Check elsewhere to see if the socket has been closed.

    Have you tried running the code in the debugger (gdb)
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21