views:

27

answers:

1

I asked this question before and had no resolution (still having the problem). I am stumped because the function returned without error and NO DATA was sent! This code works on Linux ... the VxWorks version does not work (sendto does not send, though it returns without an ERROR).

The synopsis - I am writing a simple echo server - The server successfully receives the data (from an x86 box) and claims it successfully SENT it back. However NO DATA is received on the client (netcat on an x86). This code is running on VxWorks 5.4 on a PowerPC box ...

  • I is the UDP data being buffered somehow?

  • Could another task be preventing sendto from sending? (NOT to get off on a wild goose chase here, but I taskspawn my application with a normal priority, i.e. below critical tasks like the network task etc etc ... so this is fine).

  • Could VxWorks be buffering my UDP data?

  • I HAVE setup my routing table ... pinging works!

  • There is NO firewall AFAIK ...

  • What are the nuances of sendto and what would prevent my data from reaching the client ...

    while(1) {

    readlen = recvfrom(sock, buf, BUFLEN, 0, (struct sockaddr *) &client_address, &slen);

    if (readlen == ERROR) { printf("RECVFROM FAILED()/n"); return (ERROR); }

    printf("Received %d bytes FROM %s:%d\nData: %s\n\n", readlen, inet_ntoa(client_address.sin_addr), ntohs(client_address.sin_port), buf);

    // Send it to right back to the client using the open UDP socket // but send it to OUTPORT client_address.sin_port = htons(OUTPORT);

    // Remember slen is a value (not an address ... in, NOT in-out) sendlen = sendto(sock, buf, BUFLEN, 0, (struct sockaddr*)&client_address, slen);

    // more code .... }

x

+1  A: 

I trust ERROR is defined as -1, right? Then are you checking the return value of the sendto(2) call? What about the errno(3) value?

One obvious problem I see in the code is that you give BUFLEN as length of the message to be sent, while it should actually be readlen - the number of bytes you received.

Nikolai N Fetissov