gvanem / Watt-32

Watt-32 TCP/IP library and samples.
https://www.watt-32.net/
18 stars 8 forks source link

DHCP configuration timeout #94

Closed Lethja closed 10 months ago

Lethja commented 10 months ago

Addresses part of #4

This pull request removes the possibility of an infinite loop in DHCP_do_boot() and assures both 16-bit and 32-bit versions of the library can timeout of DHCP configuration even if something goes wrong elsewhere in the code. Waiting for a response could take up to 30 seconds so to prevent confusing that with the computer locking up, a dot (.) is printed to the screen every second to indicate to the user that the program is still running and busy.

Tested with:

/* Compile for DOS (Open Watcom) with 
 * `WCC -0 -bt=dos -i=INC -ml IPCONFIG` then 
 * `WLINK SYS dos LIBF LIB\WATTCPWL.LIB F IPCONFIG`
 * 
 * Compile for DOS4G (Open Watcom) with 
 * `WCC386 -3 -bt=dos -i=INC -mf IPCONFIG` then 
 * `WLINK SYS dos4g LIBF LIB\WATTCPWF.LIB F IPCONFIG`
 */

#include <stdio.h>
#include <tcp.h>

int main() {
    struct in_addr addr;

    sock_init();
    addr.s_addr = htonl(my_ip_addr);
    printf("Address: %s\n", inet_ntoa(addr));

    return 0;
}
gvanem commented 10 months ago

It has been a long time since I've tried DHCP (I always use a fixed IP-address). So I trust this PR is good. Merging and many thanks!