FreeCalypso > hg > fc-selenite
comparison src/g23m-fad/tcpip/rnet/rnet_rt/rnet_rt_api_shutdown.c @ 1:d393cd9bb723
src/g23m-*: initial import from Magnetite
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 15 Jul 2018 04:40:46 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
0:b6a5e36de839 | 1:d393cd9bb723 |
---|---|
1 /** | |
2 * @file rnet_rt_api_shutdown.c | |
3 * | |
4 * RNET_RT API | |
5 * | |
6 * @author Regis Feneon | |
7 * @version 0.1 | |
8 */ | |
9 | |
10 /* | |
11 * $Id: rnet_rt_api_shutdown.c,v 1.3 2002/10/30 15:23:34 rf Exp $ | |
12 * $Name: ti_20021030 $ | |
13 * | |
14 * History: | |
15 * | |
16 * Date Author Modification | |
17 * -------------------------------------------------- | |
18 * 3/22/2002 Regis Feneon Create | |
19 * | |
20 * (C) Copyright 2002 by TI, All Rights Reserved | |
21 * | |
22 */ | |
23 | |
24 #include "rnet_cfg.h" | |
25 #ifdef RNET_CFG_REAL_TRANSPORT | |
26 | |
27 #include "rnet_rt_i.h" | |
28 #include "rnet_rt_env.h" | |
29 | |
30 /** | |
31 * Disables the sending on a socket and informs the peer | |
32 * about it. | |
33 * | |
34 * Subsequent calls to the send function are disallowed. | |
35 * For TCP sockets, a FIN will be sent after all data is sent and acknowledged by the receiver. | |
36 * The rnet_shutdown function does not frees the connection ID. Any resources attached | |
37 * to the ID will not be freed until rnet_close is invoked. | |
38 * | |
39 * To assure that all data is sent and received on a connection (TCP) before it | |
40 * is closed, an application should use rnet_shutdown to close connection before calling | |
41 * rnet_close. For example, to initiate a graceful disconnect: | |
42 * 1) Call rnet_shutdown. | |
43 * 2) When RNET_ERROR_IND with RNET_CONN_CLOSED is received, call rnet_recv until | |
44 * the len parameter is zero. | |
45 * 3) Call rnet_close. | |
46 * | |
47 * Following technique describes how to minimize the chance of problems | |
48 * occurring during connection teardown. In this example, the client is responsible for | |
49 * initiating a graceful shutdown. | |
50 * | |
51 * Client Side Server Side | |
52 * (1) Invoke rnet_shutdown to | |
53 * signal end of session and that | |
54 * client has no more data to send. | |
55 * (2) Receive RNET_ERROR_IND with RNET_CONN_CLOSED, | |
56 * indicating graceful shutdown in progress | |
57 * and that all data has been received. | |
58 * (3) Send any remaining response data with rnet_send. | |
59 * (5') Get RNET_RECV_IND and (4) Invoke rnet_shutdown to | |
60 * invoke rnet_recv to get any indicate server has no more data to send. | |
61 * response data sent by server. | |
62 * (5) Receive RNET_ERROR_IND (4') Invoke rnet_close. | |
63 * with RNET_CONN_CLOSED. | |
64 * (6) Invoke rnet_close. | |
65 * | |
66 * The timing sequence is maintained from step (1) to step (6) between the client and | |
67 * the server, except for step (4') and (5') which only has local timing significance in | |
68 * the sense that step (5) follows step (5') on the client side while step (4') follows | |
69 * step (4) on the server side, with no timing relationship with the remote party. | |
70 * | |
71 * @param desc Connection identifier. | |
72 * @return RNET_NOT_INITIALIZED NET subsystem not initialized (internal error). | |
73 * RNET_INTERNAL_ERR Network subsystem failed. | |
74 * RNET_INVALID_PARAMETER The connection ID is invalid. | |
75 * The descriptor is not connected (TCP only). | |
76 * RNET_NOT_READY Still processing a callback function. | |
77 * RNET_OK Connection shutdown, sending impossible | |
78 * RNET_ERROR_IND with the parameter RNET_CONN_CLOSED | |
79 * will be sent to the peer. | |
80 */ | |
81 | |
82 T_RNET_RET rnet_rt_shutdown (T_RNET_DESC * desc) | |
83 { | |
84 int err; | |
85 | |
86 /* stop sending data */ | |
87 rvf_lock_mutex( &rnet_rt_env_ctrl_blk_p->mutex); | |
88 err = ngSAIOShutdown( (NGsock *) desc, 1); | |
89 rvf_unlock_mutex( &rnet_rt_env_ctrl_blk_p->mutex); | |
90 | |
91 return( rnet_rt_ngip_error( err)); | |
92 } | |
93 | |
94 #endif /* ifdef RNET_CFG_REAL_TRANSPORT */ | |
95 |