?? tcp_server_demo.lst
字號:
C51 COMPILER V7.06 TCP_SERVER_DEMO 11/26/2004 11:32:46 PAGE 1
C51 COMPILER V7.06, COMPILATION OF MODULE TCP_SERVER_DEMO
OBJECT MODULE PLACED IN .\8052-obj\tcp_server_demo.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE tcp_server_demo.c LARGE OPTIMIZE(SIZE) BROWSE INTVECTOR(0X2000) INCDIR(D:\W
-ork\opentcp\1-0-2\src\include\) DEFINE(MONITOR,CS8900) DEBUG OBJECTEXTEND CODE SYMBOLS PRINT(.\8052-lst\tcp_server_demo.
-lst) PREPRINT(.\8052-lst\tcp_server_demo.i) OBJECT(.\8052-obj\tcp_server_demo.obj)
stmt level source
1 /*
2 *Copyright (c) 2000-2002 Viola Systems Ltd.
3 *All rights reserved.
4 *
5 *Redistribution and use in source and binary forms, with or without
6 *modification, are permitted provided that the following conditions
7 *are met:
8 *
9 *1. Redistributions of source code must retain the above copyright
10 *notice, this list of conditions and the following disclaimer.
11 *
12 *2. Redistributions in binary form must reproduce the above copyright
13 *notice, this list of conditions and the following disclaimer in the
14 *documentation and/or other materials provided with the distribution.
15 *
16 *3. The end-user documentation included with the redistribution, if
17 *any, must include the following acknowledgment:
18 * "This product includes software developed by Viola
19 * Systems (http://www.violasystems.com/)."
20 *
21 *Alternately, this acknowledgment may appear in the software itself,
22 *if and wherever such third-party acknowledgments normally appear.
23 *
24 *4. The names "OpenTCP" and "Viola Systems" must not be used to
25 *endorse or promote products derived from this software without prior
26 *written permission. For written permission, please contact
27 *opentcp@opentcp.org.
28 *
29 *5. Products derived from this software may not be called "OpenTCP",
30 *nor may "OpenTCP" appear in their name, without prior written
31 *permission of the Viola Systems Ltd.
32 *
33 *THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
34 *WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
35 *MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
36 *IN NO EVENT SHALL VIOLA SYSTEMS LTD. OR ITS CONTRIBUTORS BE LIABLE
37 *FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
38 *CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
39 *SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
40 *BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
41 *WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
42 *OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
43 *EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
44 *====================================================================
45 *
46 *OpenTCP is the unified open source TCP/IP stack available on a series
47 *of 8/16-bit microcontrollers, please see <http://www.opentcp.org>.
48 *
49 *For more information on how to network-enable your devices, or how to
50 *obtain commercial technical support for OpenTCP, please see
51 *<http://www.violasystems.com/>.
52 */
53
C51 COMPILER V7.06 TCP_SERVER_DEMO 11/26/2004 11:32:46 PAGE 2
54 /** \file tcp_server_demo.c
55 * \ingroup opentcp_example
56 * \brief Demonstration of a possible scenario of writing TCP applications
57 * \author
58 * \li Vladan Jovanovic (vladan.jovanovic@violasystems.com)
59 * \version 1.0
60 * \date 10.10.2002
61 * \bug
62 * \warning
63 * \li This example is given for demonstration purposes only. It
64 * was not tested for correct operation.
65 * \todo
66 *
67 * Blank TCP demo application showing TCP functions and how applications
68 * might use them. Please note that this is an example for a TCP server
69 * application - the kind of application that waits for a connection and
70 * does not initiate connection establishment towards other hosts.
71 */
72 #include <inet/debug.h>
*** WARNING C318 IN LINE 72 OF tcp_server_demo.c: can't open file 'inet/debug.h'
73 #include <inet/datatypes.h>
*** WARNING C318 IN LINE 73 OF tcp_server_demo.c: can't open file 'inet/datatypes.h'
74 #include <inet/globalvariables.h>
*** WARNING C318 IN LINE 74 OF tcp_server_demo.c: can't open file 'inet/globalvariables.h'
75 #include <inet/system.h>
*** WARNING C318 IN LINE 75 OF tcp_server_demo.c: can't open file 'inet/system.h'
76 #include <inet/tcp_ip.h>
77
78 UINT8 code HelloMsg[] = "Hello. I am OpenTcp Demo Server\r\n";
*** ERROR C129 IN LINE 78 OF TCP_SERVER_DEMO.C: missing ';' before 'code'
79 UINT8 Buffer[1000];
80 UINT16 BufferLen;
81
82 extern UINT8 tcpc_demo_senddata;
83
84 /* The applications that use TCP must implement following function stubs */
85 /* void application_name_init (void) - call once when processor starts */
86 /* void application_name_run (void) - call periodically on main loop */
87 /* INT32 application_name_eventlistener (INT8, UINT8, UINT32, UINT32) */
88 /* - called by TCP input process to inform arriving data, errors etc */
89
90 /* These will probably go to some include file */
91 void tcps_demo_init(void);
92 void tcps_demo_run(void);
93 INT32 tcps_demo_eventlistener(INT8 , UINT8 , UINT32 , UINT32 ) reentrant;
94
95 /** \brief Socket handle holder for this application
96 *
97 * This variable holds the assigned socket handle. Note that this application
98 * will reserve one TCP socket immediately and will not release it. For
99 * saving resources, TCP sockets can also be allocated/deallocated
100 * dynamically.
101 */
102 INT8 tcps_demo_soch;
103
104 UINT8 tcps_demo_senddata; /**< Used to trigger data sending */
105
106 #define TCPS_DEMO_PORT 5001 /**< Port number on which we'll be listening for incoming connections */
107
108 /* Internal function used for sending data to a predefined host */
109 INT16 tcps_demo_send(void);
C51 COMPILER V7.06 TCP_SERVER_DEMO 11/26/2004 11:32:46 PAGE 3
110
111 /* Initialize resources needed for the TCP server application */
112 void tcps_demo_init(void)
113 {
114
115 DEBUGOUT("Initializing TCP server application. \r\n");
116
117 /* Get socket:
118 * TCP_TYPE_SERVER - type of TCP socket is server
119 * TCP_TOS_NORMAL - no other type of service implemented so far
120 * TCP_DEF_TOUT - timeout value in seconds. If for this many seconds
121 * no data is exchanged over the TCP connection the socket will be
122 * closed.
123 * tcps_demo_eventlistener - pointer to event listener function for
124 * this socket.
125 */
126
127 tcps_demo_soch = tcp_getsocket(TCP_TYPE_SERVER, TCP_TOS_NORMAL, TCP_DEF_TOUT, tcps_demo_eventlistener);
128
129 if( tcps_demo_soch < 0 )
130 {
131 DEBUGOUT("TCP server unable to get socket. Resetting!!!\r\n");
132 RESET_SYSTEM();
133 }
134
135 /* Put it to listen on some port */
136 tcp_listen(tcps_demo_soch,TCPS_DEMO_PORT);
137
138 /* for now no data sending */
139 tcps_demo_senddata=0;
140 }
141
142 void tcps_demo_run(void)
143 {
144
145 UINT8 i;
146
147 /* do maybe some other TCP server app stuff
148 * .....
149 */
150
151 if(tcps_demo_senddata){
152 if(tcps_demo_send()!=-1)
153 tcps_demo_senddata=0;
154 }
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -