Mercurial > nand-ecoscentric
view packages/net/tcpip/current/tests/socket_test.c @ 97:ced4577552cd ecos-sw-2000-06-06
Merge from eCos master repository on 2000-06-06-08:44:00-BST
| author | jlarmour |
|---|---|
| date | Tue, 06 Jun 2000 08:39:36 +0000 |
| parents | |
| children | 6ed91473a1cd |
line wrap: on
line source
//========================================================================== // // tests/socket_test.c // // Test network socket functions // //========================================================================== //####COPYRIGHTBEGIN#### // // ------------------------------------------- // The contents of this file are subject to the Red Hat eCos Public License // Version 1.1 (the "License"); you may not use this file except in // compliance with the License. You may obtain a copy of the License at // http://www.redhat.com/ // // Software distributed under the License is distributed on an "AS IS" // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the // License for the specific language governing rights and limitations under // the License. // // The Original Code is eCos - Embedded Configurable Operating System, // released September 30, 1998. // // The Initial Developer of the Original Code is Red Hat. // Portions created by Red Hat are // Copyright (C) 1998, 1999, 2000 Red Hat, Inc. // All Rights Reserved. // ------------------------------------------- // //####COPYRIGHTEND#### //####BSDCOPYRIGHTBEGIN#### // // ------------------------------------------- // // Portions of this software may have been derived from OpenBSD or other sources, // and are covered by the appropriate copyright disclaimers included herein. // // ------------------------------------------- // //####BSDCOPYRIGHTEND#### //========================================================================== //#####DESCRIPTIONBEGIN#### // // Author(s): gthomas // Contributors: gthomas // Date: 2000-01-10 // Purpose: HLD // Description: // // //####DESCRIPTIONEND#### // //========================================================================== // socket test code #include <network.h> #define STACK_SIZE CYGNUM_HAL_STACK_SIZE_TYPICAL static char stack[STACK_SIZE]; static cyg_thread thread_data; static cyg_handle_t thread_handle; extern void cyg_test_exit(void); void net_test(cyg_addrword_t param) { int s; int one = 1; diag_printf("Start socket test\n"); s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); diag_printf("socket() = %d\n", s); s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); diag_printf("socket() = %d\n", s); if (setsockopt(s, SOL_SOCKET, SO_BROADCAST, &one, sizeof(one))) { perror("setsockopt"); } cyg_test_exit(); } void cyg_start(void) { // Create a main thread, so we can run the scheduler and have time 'pass' cyg_thread_create(10, // Priority - just a number net_test, // entry 0, // entry parameter "Network test", // Name &stack[0], // Stack STACK_SIZE, // Size &thread_handle, // Handle &thread_data // Thread data structure ); cyg_thread_resume(thread_handle); // Start it cyg_scheduler_start(); }
