Mistake on this page?
Report an issue in GitHub or email us
TCPServer.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 ARM Limited
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 /** @file TCPServer.h Deprecated TCPServer class */
18 /** \addtogroup netsocket
19  * @{*/
20 
21 #ifndef TCPSERVER_H
22 #define TCPSERVER_H
23 
24 #include "netsocket/InternetSocket.h"
25 #include "netsocket/TCPSocket.h"
26 #include "netsocket/NetworkStack.h"
28 
29 
30 /** TCP socket server
31  */
32 class TCPServer : public TCPSocket {
33 public:
34  /** Create an uninitialized socket
35  *
36  * Must call open to initialize the socket on a network stack.
37  */
38  MBED_DEPRECATED_SINCE("mbed-os-5.10",
39  "TCPServer is deprecated, use TCPSocket")
40  TCPServer();
41 
42  /** Create a socket on a network interface
43  *
44  * Creates and opens a socket on the network stack of the given
45  * network interface.
46  *
47  * @param stack Network stack as target for socket
48  */
49  template <typename S>
50  MBED_DEPRECATED_SINCE("mbed-os-5.10",
51  "TCPServer is deprecated, use TCPSocket")
52  TCPServer(S *stack)
53  {
54  open(stack);
55  }
56 
57  /** Destroy a socket
58  *
59  * Closes socket if the socket is still open
60  */
61  virtual ~TCPServer();
62 
63  // Allow legacy TCPServer::accept() to override inherited Socket::accept()
64  using TCPSocket::accept;
65 
66  /** Accepts a connection on a TCP socket
67  *
68  * The server socket must be bound and set to listen for connections.
69  * On a new connection, creates a network socket using the specified
70  * socket instance.
71  *
72  * By default, accept blocks until data is sent. If socket is set to
73  * non-blocking or times out, NSAPI_ERROR_WOULD_BLOCK is returned
74  * immediately.
75  *
76  * @param connection TCPSocket instance that will handle the incoming connection.
77  * @param address Destination for the remote address or NULL
78  * @return 0 on success, negative error code on failure
79  */
80  MBED_DEPRECATED_SINCE("mbed-os-5.10",
81  "TCPServer::accept() is deprecated, use Socket *Socket::accept() instead")
82  nsapi_error_t accept(TCPSocket *connection, SocketAddress *address = NULL);
83 };
84 
85 #endif
86 
87 /** @} */
nsapi_error_t open(NetworkStack *stack)
Open a network socket on the network stack of the given network interface.
nsapi_error_t accept(TCPSocket *connection, SocketAddress *address=NULL)
Accepts a connection on a TCP socket.
virtual TCPSocket * accept(nsapi_error_t *error=NULL)
Accepts a connection on a socket.
virtual ~TCPServer()
Destroy a socket.
Network Interface base class.
TCP socket server.
Definition: TCPServer.h:32
signed int nsapi_error_t
Type used to represent error codes.
Definition: nsapi_types.h:95
TCPServer()
Create an uninitialized socket.
SocketAddress class.
Definition: SocketAddress.h:35
TCP socket connection.
Definition: TCPSocket.h:32
NetworkStack class.
TCPSocket class.
#define MBED_DEPRECATED_SINCE(D, M)
MBED_DEPRECATED("message string") Mark a function declaration as deprecated, if it used then a warnin...
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.