]> git.proxmox.com Git - mirror_edk2.git/blob - StdLib/BsdSocketLib/shutdown.c
Fix send to properly wait while long transmits are in progress
[mirror_edk2.git] / StdLib / BsdSocketLib / shutdown.c
1 /** @file
2 Implement the shutdown API.
3
4 Copyright (c) 2011, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #include <SocketInternals.h>
16
17
18 /**
19 Shutdown the socket receive and transmit operations
20
21 The ::shutdown routine stops socket receive and transmit operations.
22 The
23 <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/shutdown.html">POSIX</a>
24 documentation is available online.
25
26 @param [in] s Socket file descriptor returned from ::socket.
27
28 @param [in] how Which operations to shutdown
29
30 @returns ::shutdown returns the zero (0) if successful or -1 when an
31 error occurs. In the latter case, errno contains more details.
32
33 **/
34 int
35 shutdown (
36 int s,
37 int how
38 )
39 {
40 int RetVal;
41 EFI_SOCKET_PROTOCOL * pSocketProtocol;
42 EFI_STATUS Status;
43
44 //
45 // Assume failure
46 //
47 RetVal = -1;
48
49 //
50 // Locate the context for this socket
51 //
52 pSocketProtocol = BslFdToSocketProtocol ( s, NULL, &errno );
53 if ( NULL != pSocketProtocol ) {
54 //
55 // Receive the data from the socket
56 //
57 Status = pSocketProtocol->pfnShutdown ( pSocketProtocol,
58 how,
59 &errno );
60 if ( !EFI_ERROR ( Status )) {
61 //
62 // Success
63 //
64 RetVal = 0;
65 }
66 }
67
68 //
69 // Return the operation status
70 //
71 return RetVal;
72 }