-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Fix TCPSocket::accept() #7992
Fix TCPSocket::accept() #7992
Conversation
This one was actually always return NULL, and unsted because we only have tests with one device. We will add the testcase for this soon
Tested manually by modifying the TEST_APP from Mbed OS diff --git i/TEST_APPS/device/socket_app/cmd_socket.cpp w/TEST_APPS/device/socket_app/cmd_socket.cpp
index 4aefe700d..0d321159f 100644
--- i/TEST_APPS/device/socket_app/cmd_socket.cpp
+++ w/TEST_APPS/device/socket_app/cmd_socket.cpp
@@ -1125,22 +1125,13 @@ static int cmd_socket(int argc, char *argv[])
}
} else if (COMMAND_IS("accept")) {
- SocketAddress addr;
int32_t id;
- if (!cmd_parameter_int(argc, argv, "accept", &id)) {
- cmd_printf("Need new socket id\r\n");
- return CMDLINE_RETCODE_INVALID_PARAMETERS;
- }
- SInfo *new_info = get_sinfo(id);
- if (!new_info) {
- cmd_printf("Invalid socket id\r\n");
- return CMDLINE_RETCODE_FAIL;
- }
- TCPSocket *new_sock = static_cast<TCPSocket *>(&new_info->socket());
- nsapi_error_t ret = static_cast<TCPServer &>(info->socket()).accept(new_sock, &addr);
+ nsapi_error_t ret;
+ TCPSocket *new_sock = static_cast<TCPSocket &>(info->socket()).accept(&ret);
if (ret == NSAPI_ERROR_OK) {
- cmd_printf("TCPServer::accept() new socket sid: %d connection from %s port %d\r\n",
- new_info->id(), addr.get_ip_address(), addr.get_port());
+ SInfo *new_info = new SInfo(new_sock);
+ m_sockets.push_back(new_info);
+ cmd_printf("TCPServer::accept() new socket sid: %d\r\n", new_info->id());
}
return handle_nsapi_error("TCPServer::accept()", ret);
} |
/morph build |
Build : SUCCESSBuild number : 3040 Triggering tests/morph test |
Test : SUCCESSBuild number : 2813 |
Exporter Build : SUCCESSBuild number : 2656 |
Thanks @SeppoTakalo. We'll bring it into the 5.10.1 patch. |
Description
TCPSocket::accept() was actually always return NULL, and unsted because we only
have tests with one device.
We will add the testcase for this soon.
This fixes #7936
@kjbracey-arm please review
Pull request type