Hello!
And here is the Question:
I made a Network Program.
When I recieve some data with the recv-function, can I then get the Name of the Computer which sent the data. But I think its not the name you got normaly with GetComputerName-function. It must be another one.
thx for help...
And here is the Question:
I made a Network Program.
When I recieve some data with the recv-function, can I then get the Name of the Computer which sent the data. But I think its not the name you got normaly with GetComputerName-function. It must be another one.
thx for help...
Just put code into the client software to sent the information to you.
Regards, P1
Regards, P1
You can use "gethostname" from winsock2 to get the network computer name.
Start with WSAStartup and close with WSACleanup.
Start with WSAStartup and close with WSACleanup.
When a connection request is made, you can extract the IP address of the computer trying to connect. In addition, you can use GetHostName to get the name. Once you accept the request you get the socket handle, just associate the name to the socket handle in some kind of array or structure.
When you recieve data, look at the socket handle that the data was recieved on and use your array/structure to lookup the hostname from that.
That's something like I would do it, there may be other/better ways.
When you recieve data, look at the socket handle that the data was recieved on and use your array/structure to lookup the hostname from that.
That's something like I would do it, there may be other/better ways.
thx I tried it
and it works
and it works