It finally happened. The class TCPServer, that has been long deprecated, was totally eliminated in Mbed OS 6. This would be OK if TCPSocket class supplied the same functionality, but alas there is a small difference which ruins my code. The problem is in the format of accept(…) method:
nsapi_error_t TCPServer::accept( TCPSocket * connection, SocketAddress * address = NULL ) TCPSocket * TCPSocket::accept ( nsapi_error_t * error = NULL )
While TCPServer::accept(…) takes a pointer to an existing instance of TCPSocket as a parameter, TCPSocket::accept(…) creates a new instance of the same class all by itself and returns a pointer to it. This is all very well until one decides to build their own class inheriting from TCPSocket and extending its functionality. Obviously the new class should override TCPSocket::accept(…) method, so that a new instance of this class could be constructed and not one of the class TCPSocket, but I don’t see any reasonable way to do it.
With TCPServer::accept(…) this was not a problem, since it didn’t construct any objects by itself and I could supply it with a pointer of an instance of my extended class.
So the questions to the Mbed developers is: with all regards, can we have an overloaded accept method in TCPSocket similar to the one in TCPServer, if not return TCPServer class into the library altogether?
Or maybe I’m missing something and there IS a way to solve this little problem?