The following function shows how to obtain your machine's host name (IP address or domain name) programmatically, using the Windows Sockets APIs, and use it for initializing the server side.
CString GetDefaultConnection()
{
CString s;
WSADATA wsaData;
int iResult = WSAStartup(MAKEWORD(2,2), &wsaData);
if (iResult == NO_ERROR)
{
char Hostname[100];
if(gethostname( Hostname, sizeof( Hostname )) != SOCKET_ERROR)
{
HOSTENT* pHostEnt = gethostbyname( Hostname );
if(pHostEnt)
{
if(pHostEnt->h_addr_list[0])
{
s.Format("%d.%d.%d.%d",
(int) (BYTE) pHostEnt->h_addr_list[0][0],
(int) (BYTE) pHostEnt->h_addr_list[0][1],
(int) (BYTE) pHostEnt->h_addr_list[0][2],
(int) (BYTE) pHostEnt->h_addr_list[0][3]);
}
}
}
WSACleanup();
}
return s;
}
If there are multiple names (IP addresses), you can force any one you want.
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document