Skip to content

Deprecate TCP/UDPSocket open-calling constructors #8794

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion UNITTESTS/features/netsocket/TCPSocket/test_TCPSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ TEST_F(TestTCPSocket, constructor)

TEST_F(TestTCPSocket, constructor_parameters)
{
TCPSocket socketParam = TCPSocket(dynamic_cast<NetworkStack *>(&stack));
TCPSocket socketParam = TCPSocket();
socketParam.open(dynamic_cast<NetworkStack *>(&stack));
const SocketAddress a("127.0.0.1", 1024);
EXPECT_EQ(socketParam.connect(a), NSAPI_ERROR_OK);
}
Expand Down
6 changes: 6 additions & 0 deletions features/netsocket/TCPSocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,14 @@ class TCPSocket : public InternetSocket {
* network interface.
*
* @param stack Network stack as target for socket
*
* @deprecated since mbed-os-5.11
*/
template <typename S>
MBED_DEPRECATED_SINCE("mbed-os-5.11",
"The TCPSocket(S *stack) constructor is deprecated."
"It discards the open() call return value."
"Use another constructor and call open() explicitly, instead.")
TCPSocket(S *stack)
{
open(stack);
Expand Down
16 changes: 0 additions & 16 deletions features/netsocket/TLSSocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,6 @@ class TLSSocket : public TLSSocketWrapper {
*/
virtual ~TLSSocket();

/** Create a socket on a network interface
*
* Creates and opens a socket on the network stack of the given
* network interface.
* If hostname is also given, user is not required to call set_hostname() later.
*
* @param stack Network stack as target for socket
* @param hostname Hostname used for certificate verification
*/
template <typename S>
TLSSocket(S *stack, const char *hostname = NULL) : TLSSocketWrapper(&tcp_socket, hostname)
{
nsapi_error_t ret = tcp_socket.open(stack);
MBED_ASSERT(ret == NSAPI_ERROR_OK);
}

/** Opens a socket
*
* Creates a network socket on the network stack of the given
Expand Down
5 changes: 5 additions & 0 deletions features/netsocket/UDPSocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,13 @@ class UDPSocket : public InternetSocket {
*
* @tparam S Type of the Network stack.
* @param stack Network stack as target for socket.
* @deprecated since mbed-os-5.11
*/
template <typename S>
MBED_DEPRECATED_SINCE("mbed-os-5.11",
"The UDPSocket(S *stack) constructor is deprecated"
"It discards the open() call return value."
"Use another constructor and call open() explicitly, instead.")
UDPSocket(S *stack)
{
open(stack);
Expand Down