[ https://issues.apache.org/jira/browse/THRIFT-2156?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15386530#comment-15386530 ]
Jens Geyer commented on THRIFT-2156: ------------------------------------ {code} char port[sizeof("65535")]; std::memset(&hints, 0, sizeof(hints)); hints.ai_family = PF_UNSPEC; hints.ai_socktype = SOCK_STREAM; hints.ai_flags = AI_PASSIVE | AI_ADDRCONFIG; snprintf(port, sizeof("65535"), "%d", port_); {code} why not {code} const size_t bufsize = sizeof("65535"); char port[bufsize]; snprintf(port, bufsize, "%d", port_); std::memset(&hints, 0, sizeof(hints)); hints.ai_family = PF_UNSPEC; hints.ai_socktype = SOCK_STREAM; hints.ai_flags = AI_PASSIVE | AI_ADDRCONFIG; {code} seems less prone to error to me. I have not tested this, so it may not even compile. > TServerSocket::listen() is throwing exceptions with misleading information > -------------------------------------------------------------------------- > > Key: THRIFT-2156 > URL: https://issues.apache.org/jira/browse/THRIFT-2156 > Project: Thrift > Issue Type: Bug > Components: C++ - Library > Affects Versions: 0.9 > Reporter: Frank Meerkoetter > Assignee: James E. King, III > Priority: Minor > Attachments: errno_copy.patch > > > Due to a problem with bind() an exception was thrown. > The text was: > "Could not bind: Transport endpoint is not connected" > which doesn't make sense. > It turned out that errno had been overwritten. > The correct text would have been: > "Could not bind: Address already in use" -- This message was sent by Atlassian JIRA (v6.3.4#6332)