Re: NIST time server - TCPIP problem

"Roger Hunt [email protected] [rabbit-semi]" <[email protected]>
Newsgroups gmane.comp.hardware.rabbit-semiconductor
Message-ID <[email protected]>
Hi Scott,

Thank you for the prompt reply.  I checked the Dynamic C TCP/IP manual, 
which says the MAX_SOCKETS define has been deprecated.  I did not have a 
value defined for MAX_TCP_SOCKET_BUFFERS, so was hoping you had nailed 
the problem.  Since the default value is 4, I added the line:
    #define MAX_TCP_SOCKET_BUFFERS 8
and when that did not work, made it 16.  That did not work either.

The code which is failing is:

     printf("\nConnecting with NIST server ...\n");
     sock_init();
     while (ifpending(IF_DEFAULT) == IF_COMING_UP)
     {
         tcp_tick(NULL);
     }
     ip=resolve(NIST_SERVER_IP);
     tcp_open(&s, 0, ip, NIST_PORT, NULL);
     sock_wait_established(&s, NIST_TIMEOUT, NULL, &status);
     sock_mode(&s, TCP_MODE_ASCII);
     // Receive and process data -- the server will close the connection,
     // which will cause execution to continue at sock_err below.
     while (tcp_tick(&s))
     {
         sock_wait_input(&s, NIST_TIMEOUT, NULL, &status);
         sock_gets(&s, buffer, 48);
     }

     sock_err:
     if (status == -1)
     {
         printf("\nConnection timed out, exiting.\n");
         exit(1);
     }

I get the "Connection timed out, exiting" message almost instantly, 
which means the sock_wait_input function is returning a status of -1, 
which according to the DC manual "indicates a reset or abort." This same 
code works if I haven't opened the http handler first.

Scott, I know absolutely nothing about TCP/IP stuff, and am really 
struggling here.  I am embarrassed to admit that I have already spent a 
couple of days on this issue.  Do you have any other ideas?

Thanks so much,

Roger


On 6/26/2014 2:07 PM, Scott Henion [email protected] [rabbit-semi] 
wrote:
>
> Look at the #defines in the docs for the # of socket buffers and max
> sockets. You probably have 1 too few.
>
> ------------------------------------------
> Scott G. Henion, Consultant
> Web site: http://SHDesigns.org
> ------------------------------------------
>



---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.