I wrote some code on VxWorks to download a file from a TFTP server using tftpLib but the get gives me a timeout:
ERR [TFTP] tftpSend:479: Transfer Timed Out.
ERR [TFTP] tftpGet:1077: File transfer error.
Error has occurred: 4915207
which isn't right as the host is reachable:
ping("3.94.213.53",3)
Pinging 3.94.213.53 (3.94.213.53) with 64 bytes of data:
Reply from 3.94.213.53 bytes=64 ttl=63 seq=0 time<1ms
Reply from 3.94.213.53 bytes=64 ttl=63 seq=1 time<1ms
Reply from 3.94.213.53 bytes=64 ttl=63 seq=2 time<1ms
and when I do this from the Linux shell, it works just as expected:
tftp -r "artifacts/ngfm.bin" -g 3.94.213.53
What might be the problem here? The get section of my code looks like:
pFile = fopen("flash:/ngfm.bin","wb");
    if (pFile != NULL) {
        /* Get file from TFTP server and write it to the file descriptor */
        if (OK == (status = tftpGet (pTftpDesc, pFilename, pFile, TFTP_CLIENT))) {
         printf("tftpGet() successful\n");
        } else {
         printf("Error has occurred: %d\n", errno); // errno is where the error is stored
        }
    } else {
        printf("Bad file pointer pFile");
    }
edit:
The code I have above the get portion is:
/*Initiate TFTP session*/
if ((pTftpDesc = tftpInit ()) == NULL)
   printf("Error on tftpInit()\n");
/*connect to TFTP host and set transfer mode*/
if ((tftpPeerSet (pTftpDesc, pHost, port) == ERROR) ||
    (tftpModeSet (pTftpDesc, pMode) == ERROR)) {
    (void) tftpQuit (pTftpDesc);
    printf("Error on tftpPeerSet()\n");
    return ERROR;
}
				
                        
Okay, turns out that TFTP is a no go in my situation. I hooked up Wireshark and saw that my client is getting through to the server just fine on port 69. I previously have also made sure that I have port forwarding on port 69 setup in my
iptablerules properly. Now I just read this on Wikipedia:i.e. TFTP won't work for me because I need NAT and it has to be secure. I'll need to go with a protocol that's connection orriented, ftp e.g.
I found that the standar
VxWorkslibrary also containsftpLib.h(http://www.vxdev.com/docs/vx55man/vxworks/ref/ftpLib.html#ftpLs) that will hopefully resolve my NAT issues as FTP works with connection based TCP.