| | 326 | std::ostringstream addr_stream; |
|---|
| | 327 | |
|---|
| | 328 | #if defined(VPR_OS_Windows) |
|---|
| | 329 | // inet_ntoa() returns a pointer to static memory, which means that |
|---|
| | 330 | // it is not reentrant. Unfortunately, WinSock2 does not provide |
|---|
| | 331 | // inet_ntop(). The memory returned is guaranteed to be valid until |
|---|
| | 332 | // the next socket call in this thread, so there should not be a |
|---|
| | 333 | // race condition here. |
|---|
| | 334 | const char* temp_addr = inet_ntoa(addr->sin_addr); |
|---|
| | 335 | |
|---|
| | 336 | if ( NULL != temp_addr ) |
|---|
| | 337 | { |
|---|
| | 338 | addr_stream << temp_addr; |
|---|
| | 339 | } |
|---|
| | 340 | #else |
|---|
| 327 | | #if defined(VPR_OS_Windows) |
|---|
| 328 | | // inet_ntoa() returns a pointer to static memory, which means that |
|---|
| 329 | | // it is not reentrant. There is a race condition here between the |
|---|
| 330 | | // time of the return from inet_ntoa() and the time that strcpy() |
|---|
| 331 | | // actually copies the memory. Unfortunately, WinSock2 does not |
|---|
| 332 | | // provide inet_ntop(). |
|---|
| 333 | | strcpy(netaddr, inet_ntoa(addr->sin_addr)); |
|---|
| 334 | | char* temp_addr = netaddr; |
|---|
| 335 | | #else |
|---|