MCPcopy Create free account
hub / github.com/Kitware/VTK / GetPort

Method GetPort

Common/System/vtkSocket.cxx:500–524  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

498
499//------------------------------------------------------------------------------
500int vtkSocket::GetPort(int sock)
501{
502#ifndef VTK_SOCKET_FAKE_API
503 struct sockaddr_in sockinfo;
504 memset(&sockinfo, 0, sizeof(sockinfo));
505#if defined(VTK_HAVE_GETSOCKNAME_WITH_SOCKLEN_T)
506 socklen_t sizebuf = sizeof(sockinfo);
507#else
508 int sizebuf = sizeof(sockinfo);
509#endif
510
511 int iErr;
512 vtkRestartInterruptedSystemCallMacro(
513 getsockname(sock, reinterpret_cast<sockaddr*>(&sockinfo), &sizebuf), iErr);
514 if (iErr == vtkSocketErrorReturnMacro)
515 {
516 vtkSocketErrorMacro(vtkErrnoMacro, "Socket error in call to getsockname.");
517 return 0;
518 }
519 return ntohs(sockinfo.sin_port);
520#else
521 static_cast<void>(sock);
522 return -1;
523#endif
524}
525
526//------------------------------------------------------------------------------
527void vtkSocket::CloseSocket(int socketdescriptor)

Callers 3

vtkImageWriter.cxxFile · 0.45
GetServerPortMethod · 0.45
ProcessRequestMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected