FPGA, CPLD, and ASIC solutions from Altera
  • Download Center
  • Literature
Sign in/register
myAltera Account
Welcome
  •   myAltera
  •   Logout
  • Products
    • Devices
    • Design Software
    • Intellectual Property
    • Development Kits/Cables
    • Design & Support Services
    • Literature
  • End Markets
    • Automotive
    • Broadcast
    • Computer & Storage
    • Consumer
    • Industrial
    • Medical
    • Military
    • Test & Measurement
    • Wireless
    • Wireline
  • Technology
    • DSP
    • External Memory
    • Embedded Processing
    • Transceivers
    • Parallel I/O
    • Signal Integrity
    • System Integration
  • Training
    • Training Courses
    • University Program
    • Webcasts & Videos
    • Demonstrations
    • Events Calendar
  • Support
    • Design & Support Resources
    • Knowledge Database
    • Devices
    • Design Software
    • Intellectual Property
    • Development Kits/Cables
    • Design Examples
    • Downloads
    • User Communities/Forums
    • mySupport
  • About Altera
    • About Us
    • Environmental
    • Customer Successes
    • Partners
    • Newsroom
    • Investor Relations
    • Jobs
    • Contact Us
  • Buy Online
    • Devices
    • Design Software
    • Development & Education Kits
    • Cables & Programming Hardware
    • Intellectual Property
  • Entire Site
  • Part Number
  • Knowledge Database
  • Support & Technical Docs
  • Forums & Wiki
Username:  
Password:  
 
Forgot my username or password
Don't have myAltera account? Register Now.
Enter your email address:

Simple Socket Server Design Example

Home > Support > Design Examples > Nios II > Simple Socket Server Design Example

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
File Description
alt_error_handler.h Definitions for four error handlers—one each for MicroC-OS/II, the NicheStack TCP/IP stack, and the simple socket server application.
alt_error_handler.c Implementation for four error handlers—one each for MicroC-OS/II, the NicheStack TCP/IP stack, and the simple socket server application.
network_utilities.h Definitions for routines to read/write the media access controller (MAC) address and Internet protocol (IP) address.
network_utilities.c Contains routines to read/write the MAC address and IP address from non-volatile memory.
network_utilities_iniche.c 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).
iniche_init.c Contains main() and NicheStack callback to install tasks once the NicheStack TCP/IP stack has been properly initialized.
simple_socket_server.c Implementation of a simple socket server, including all necessary socket calls to handle a single socket connection and process received commands.
led.c Contains tasks to manage board LED displays.
simple_socket_server.h 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.

The use of this design is governed by, and subject to, the terms and conditions of the Altera Hardware Reference Design License Agreement.

Hardware Requirements

This example requires the following to be present in the target hardware design:

  • One of the following networking interfaces
    • LAN91C111 MAC/PHY (lan91c111 in SOPC Builder)
    • Altera® Triple Speed Ethernet MAC (tse_mac in SOPC Builder)
  • Programmable I/O (PIO), 8-bit output (led_pio in SOPC Builder)
  • PIO, 16-bit output (seven_seg_pio in SOPC Builder)
  • STDOUT device [UART or Joint Test Action Group (JTAG) UART]
  • (Optional) LCD display (lcd_display in SOPC Builder)

You can run this software design example on the Nios II hardware design examples shown in Table 2.

Table 2. Networking Interface Provided by FPGA Device Family and Design Name
Device Family Design Name
Standard-Lan91c111 Standard Full-Featured
Cyclone®   LAN91C111 LAN91C111
Cyclone II LAN91C111 Altera MAC Altera MAC
Stratix®   LAN91C111 LAN91C111
Stratix II LAN91C111 Altera MAC Altera MAC

Related Links

For more information about using this design example in your project, go to:

  • Nios II Literature
  • Nios II IDE Tutorial

Design Examples Disclaimer

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.

Rate This Page


  • Products
    • MAX/MAX II
    • Stratix/Stratix GX
    • Nios II
  • Functionality
    • Arithmetic
    • External Memory Interfaces
    • On-Chip Memory
    • Bus & I/O Functions
    • Logic
    • Interfaces & Peripherals
    • DSP
    • Communications
    • PLL & Clocking
  • Design Entry
    • Quartus II
    • Tcl
    • VHDL
    • Verilog HDL
    • C Code
    • DSP Builder
    • TimeQuest
    • On-Chip Debugging
      • SignalTap II
  • Simulation Tools
    • Mentor Graphics ModelSim
    • Cadence NCsim
    • Synopsys VCS
  • Legacy Examples
    • Graphic Editor
    • AHDL
    Please give us feedback
    Products | End Markets | Technology | Training | Support | About Altera | Buy Online
    Jobs | Investor Relations | Contact Us | Site Map | Privacy | Legal Notice
    Copyright © 1995-2010 Altera Corporation. All Rights Reserved.
    Altera Forum
    Altera
    Forum
    Twitter
    Twitter
    RSS
    RSS
    Facebook
    Facebook
    Flickr
    Flickr
    YouTube
    YouTube
    Email Updates
    Email
    Updates