comparison src/g23m-fad/tcpip/rnet/rnet_rt/rnet_rt_api_close.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_close.c
3 *
4 * RNET_RT API
5 *
6 * @author Regis Feneon
7 * @version 0.1
8 */
9
10 /*
11 * $Id: rnet_rt_api_close.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
26 #ifdef RNET_CFG_REAL_TRANSPORT
27
28 #include "rnet_rt_i.h"
29 #include "rnet_rt_env.h"
30
31 /**
32 * Closes the connection.
33 *
34 * Use it to release the connection ID so further references to it will fail with
35 * the error RNET_INVALID_PARAMETER.
36 *
37 * An application should always have a matching call to rnet_close for each successful
38 * call to rnet_new to return any resources to the system.
39 *
40 * The function may return RNET_MEMORY_ERR if no memory
41 * was available for closing the connection. If so, the application
42 * should wait and try again either by using the error message
43 * or the polling functionality.
44 * If the close succeeds, the function returns RNET_OK.
45 *
46 * The connection ID is deallocated after a call to rnet_close().
47 *
48 * @param desc Connection identifier.
49 * @return RNET_MEMORY_ERR Not enough memory is available
50 * RNET_NOT_INITIALIZED NET subsystem not initialized (internal error).
51 * RNET_INTERNAL_ERR Network subsystem failed.
52 * RNET_INVALID_PARAMETER The connection ID is invalid.
53 * RNET_NOT_READY Still processing a callback function.
54 * RNET_OK Socket closed.
55 */
56
57 T_RNET_RET rnet_rt_close (T_RNET_DESC * desc)
58 {
59 int err;
60
61 /* remove callback and close socket */
62 rvf_lock_mutex( &rnet_rt_env_ctrl_blk_p->mutex);
63 ngSAIOSetCallback( (NGsock *) desc, NULL, NULL);
64 err = ngSAIOClose( (NGsock *) desc, 1);
65 rvf_unlock_mutex( &rnet_rt_env_ctrl_blk_p->mutex);
66
67 return( rnet_rt_ngip_error( err));
68 }
69
70 #endif /* ifdef RNET_CFG_REAL_TRANSPORT */
71