This design example shows a socket server using the NicheStack TCP/IP stack-Nios® II Edition on MicroC/OS-II. The server implements simple commands to control board LEDs through a separate MicroC/OS-II task. This design example is not a complete implementation of a telnet server. This example uses the sockets interface.
Table 1 lists the software source files included in this example.
Table 1. Software Source Files Included in Simple Socket Server Design Example
Definitions for four error handlers—one each for MicroC-OS/II, the NicheStack TCP/IP stack, and the simple socket server application.
Implementation for four error handlers—one each for MicroC-OS/II, the NicheStack TCP/IP stack, and the simple socket server application.
Definitions for routines to read/write the media access controller (MAC) address and Internet protocol (IP) address.
Contains routines to read/write the MAC address and IP address from non-volatile memory.
Contains MAC address, IP address, and dynamic host configuration protocol (DHCP) routines to manage addressing. These are used by the NicheStack TCP/IP stack during initialization, but are implementation-specific (you can set your MAC address or read it from non-volatile memory).
Contains main() and NicheStack callback to install tasks once the NicheStack TCP/IP stack has been properly initialized.
Implementation of a simple socket server, including all necessary socket calls to handle a single socket connection and process received commands.
Contains tasks to manage board LED displays.
Definitions for the entire example application.
Using This Design Example
This embedded software example is installed with the Nios II Embedded Design Suite (EDS) in a directory under <Nios II kit path>/examples/software. A free evaluation version of the Nios II EDS is available. This example is available as a Nios II integrated development environment (IDE) project template. The template includes the project settings required to run this design on the supported target hardware configuration. To use this software example, it is not necessary to copy the files from the installation directory. Simply create a new C/C++ application project in the IDE, and choose the desired project template.
These design examples may only be used within Altera Corporation devices and remain the property of Altera. They are being provided on an “as-is” basis and as an accommodation; therefore, all warranties, representations, or guarantees of any kind (whether express, implied, or statutory) including, without limitation, warranties of merchantability, non-infringement, or fitness for a particular purpose, are specifically disclaimed. Altera expressly does not recommend, suggest, or require that these examples be used in combination with any other product not provided by Altera.