Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12618 Discussions

How to reboot Simple Socket Server ?

Honored Contributor II



I've implemented the Simple Socket server on a custom board. All is working fine, but I'd like to be able to start the board without the ethernet cable being connected (the server is not the main goal of this board). I'm able to detect that the cable is here or not by reading the PHY Status register, bit 10 (using Marwell88E1111). So when I detect that the cable is plugged in, I'd like to restart the network initialisation sequence, including the DHCP sequence. I've tried several things that don't work (calling netmain_init() for example creates a second ethernet interface ; calling alt_tse_phy_check_link() then dhc_setup() falls into DHCP timeout ...). Anyone has an idea or already has made this ? 



0 Kudos
1 Reply
Honored Contributor II

I think I've "dirtly" solved my problem. Before calling netmain_init(), one must close all sockets (including the primary socket, closed with socketclose(fd_listen) ), and then force the variable ifNumber to 0. Call netmain_init() and then recreate the primary socket, socket(...), bind(...) and listen(...) as in the beginning of the SSSSimpleServerTask() example. 

If you have any other better solution, don't hesitate ...
0 Kudos