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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [ecos-2.0/] [packages/] [net/] [common/] [v2_0/] [tests/] [socket_test.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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