OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [net/] [common/] [current/] [tests/] [socket_test.c] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
//==========================================================================
2
//
3
//      tests/socket_test.c
4
//
5
//      Test network socket functions
6
//
7
//==========================================================================
8
// ####BSDALTCOPYRIGHTBEGIN####                                             
9
// -------------------------------------------                              
10
// Portions of this software may have been derived from FreeBSD, OpenBSD,   
11
// or other sources, and if so are covered by the appropriate copyright     
12
// and license included herein.                                             
13
// -------------------------------------------                              
14
// ####BSDALTCOPYRIGHTEND####                                               
15
//==========================================================================
16
//#####DESCRIPTIONBEGIN####
17
//
18
// Author(s):    gthomas
19
// Contributors: gthomas
20
// Date:         2000-01-10
21
// Purpose:      HLD
22
// Description:  
23
//              
24
//
25
//####DESCRIPTIONEND####
26
//
27
//==========================================================================
28
 
29
// socket test code
30
 
31
#include <network.h>
32
 
33
#ifndef CYGPKG_LIBC_STDIO
34
#define perror(s) diag_printf(#s ": %s\n", strerror(errno))
35
#endif
36
 
37
#define STACK_SIZE CYGNUM_HAL_STACK_SIZE_TYPICAL
38
static char stack[STACK_SIZE];
39
static cyg_thread thread_data;
40
static cyg_handle_t thread_handle;
41
 
42
extern void
43
cyg_test_exit(void);
44
 
45
void
46
net_test(cyg_addrword_t param)
47
{
48
    int s;
49
    int one = 1;
50
 
51
    diag_printf("Start socket test\n");
52
 
53
    s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
54
    diag_printf("socket() = %d\n", s);
55
    s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
56
    diag_printf("socket() = %d\n", s);
57
 
58
    if (setsockopt(s, SOL_SOCKET, SO_BROADCAST, &one, sizeof(one))) {
59
        perror("setsockopt");
60
    }
61
 
62
    cyg_test_exit();
63
}
64
 
65
void
66
cyg_start(void)
67
{
68
    // Create a main thread, so we can run the scheduler and have time 'pass'
69
    cyg_thread_create(10,                // Priority - just a number
70
                      net_test,          // entry
71
                      0,                 // entry parameter
72
                      "Network test",    // Name
73
                      &stack[0],         // Stack
74
                      STACK_SIZE,        // Size
75
                      &thread_handle,    // Handle
76
                      &thread_data       // Thread data structure
77
            );
78
    cyg_thread_resume(thread_handle);  // Start it
79
    cyg_scheduler_start();
80
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.