how to send host name to client?

I have a server and client program. The server sends its IP address to a master web server. The client then reads this list and displays the IP addresses in a listbox. The client can then select a server and connect to it. But i also want to display the server's host name next to the IP address in the client listbox.

here is the code to send the IP address:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
  char ac[80];
	if (gethostname(ac, sizeof(ac)) == SOCKET_ERROR) 
	{
		printf("Error when getting local host name: ", WSAGetLastError()); 
		exit(0);
	}
	
	struct hostent *phe = gethostbyname(ac);
	if (phe == 0) 
	{
		printf("Error: ", WSAGetLastError()); 
		exit(0);
	}

	struct in_addr addr;
	memcpy(&addr, phe->h_addr_list[0], sizeof(struct in_addr)); // use the first ip-address
	printf("IP used by Server: %s\n", inet_ntoa(addr)); // inet_ntoa(addr) provides the local address.
	MyIP = inet_ntoa(addr);

	char SendBuf[32];
	sprintf(SendBuf, "%hhu|%s", cAddIP, MyIP);   // Send the server the IP
	WebPost(WEBSITE, WEBPAGE, SendBuf, 0);


what do i need to do to also send the host name?
You already have the local hostname, it was returned to you in Line 2 of this code snip. You should send it the same way you are sending the IP. It would help if you posted the code for "WebPost".
Topic archived. No new replies allowed.