📄 udpserv.c
字号:
/*************************************************************************/
/* */
/* Copyright (c) 1993 Accelerated Technology, Inc. */
/* */
/* PROPRIETARY RIGHTS of Accelerated Technology are involved in the */
/* subject matter of this material. All manufacturing, reproduction, */
/* use, and sales rights pertaining to this subject matter are governed */
/* by the license agreement. The recipient of this software implicitly */
/* accepts the terms of the license. */
/* */
/*************************************************************************/
/*************************************************************************/
/* */
/* FILE NAME VERSION */
/* */
/* UDPSERV.C PLUS 1.1 */
/* */
/* */
/* DESCRIPTION */
/* */
/* Example UDP Server program. */
/* Waits for data to be sent from a client. When data is */
/* received it is echoed back to the client. */
/* */
/* AUTHOR */
/* */
/* Bill Haggerty, Accelerated Technology, Inc. */
/* */
/* DATA STRUCTURES */
/* */
/* udp_server_task_ptr; Pointer to UDP client task */
/* control block. */
/* socketQueue; Pointer to socket queue */
/* control block. */
/* */
/* FUNCTIONS */
/* */
/* Application_Initialize Initialize Nucleus PLUS */
/* application environment. */
/* UDP_server_task UDP server task */
/* */
/* DEPENDENCIES */
/* */
/* config.h defines used for buffer sizes, header sizes, etc.*/
/* hostform.h Host and local machine configuration information*/
/* externs.h External definitions for functions in NCSA */
/* Telnet. */
/* nucleus.h contains system constants common to both the */
/* application and Nucleus PLUS components. */
/* socketd.h socket interface structures */
/* tcpdefs.h definitions for Nucleus - TCP/IP program */
/* */
/* HISTORY */
/* */
/* NAME DATE REMARKS */
/* */
/* B. Haggerty 06-25-1997 Created version 1.0 */
/* M. Phillips 07-14-1997 Created version 1.1 */
/* */
/*************************************************************************/
/*
* Includes
*/
#include <string.h>
#ifdef MEMORY_DEBUG
#include "memdebug.h"
#endif
#include "config.h"
#include "hostform.h"
#include "externs.h"
#include "nucleus.h"
#include "socketd.h" /* socket interface structures */
#include "tcpdefs.h"
/* Define Application data structures. */
NU_MEMORY_POOL System_Memory;
NU_TASK udp_server_task_ptr;
/* Define prototypes for function references. */
void UDP_server_task(UNSIGNED argc, VOID *argv);
/* Define external referances to global variables */
#ifdef INTERRUPT
extern sint NU_Vect_Number;
#endif /* INTERRUPT */
/* Define the Application_Initialize routine that determines the initial
Nucleus PLUS application environment. */
/*************************************************************************/
/* */
/* FUNCTION */
/* */
/* Application_Initialize */
/* */
/* DESCRIPTION */
/* */
/* Define the Application_Initialize routine that determines the */
/* initial Nucleus PLUS application environment. */
/* */
/* AUTHOR */
/* */
/* Neil Henderson, Accelerated Technology, Inc. */
/* */
/* CALLS */
/* */
/* NU_Create_Memory_Pool Create dynamic memory pool */
/* NU_Allocate_Memory Allocate memory from memory pool */
/* NU_Create_Task Create an application task. */
/* NU_Create_Queue Create a message Queue */
/* NU_Create_Semaphore Create a counting Semaphore */
/* NU_Init_Net Set up Nucleus NET internal data */
/* structures and initialize network */
/* hardware. */
/* */
/* INPUTS */
/* */
/* first_available_memory Pointer to first available */
/* memory address */
/* */
/* OUTPUTS */
/* */
/* none */
/* */
/* HISTORY */
/* */
/* NAME DATE REMARKS */
/* */
/* N. Henderson 06-28-1994 Created initial version 1.0 */
/* */
/*************************************************************************/
void Application_Initialize (void *first_available_memory)
{
VOID *pointer;
STATUS status;
/* Create a system memory pool that will be used to allocate task stacks,
queue areas, etc. */
status = NU_Create_Memory_Pool(&System_Memory, "SYSMEM",
first_available_memory, 400000, 50, NU_FIFO);
if (status != NU_SUCCESS)
{
#if (OUTPUT_OK)
printf ("Can not create the System Memory Pool.\n");
#endif /* OUTPUT_OK */
}
/* Create each task in the system. */
/* Create UDP_server_task. */
status = NU_Allocate_Memory (&System_Memory, &pointer, 2000, NU_NO_SUSPEND);
if (status != NU_SUCCESS)
{
#if (OUTPUT_OK)
printf ("Can not create memory for UDP_server_task.\n");
#endif /* OUTPUT_OK */
}
status = NU_Create_Task (&udp_server_task_ptr, "UDPSERV", UDP_server_task, 0,
NU_NULL, pointer, 2000, 3, 0, NU_PREEMPT,
NU_START);
if (status != NU_SUCCESS)
{
#if (OUTPUT_OK)
printf ("Cannot create UDP_server_task\n\r");
#endif /* OUTPUT_OK */
}
} /* end Application_Initialize */
/*************************************************************************/
/* */
/* FUNCTION */
/* */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -