Get Info from TcpClients?

korae

Member
Joined
Jan 24, 2010
Messages
22
Programming Experience
Beginner
Is there a way where the server(TcpListener) can get clients(TcpClients) IP address and Stats.BytesSent and Stats.BytesReceived of the clients network card remotely? I have a server/client project and I'm having a hard time distributing message received to designated labels. Clients send information like IP address and other stuff to the server, is it possible that clients won't send anymore the information instead the server extracts it remotely?
 
Last edited:
You could possibly keep track of bytes sent/received for each TcpClient, but depending on how you read/write on that socket it could prove difficult. None of the classes involved in these operations has this information available. A typical problem for keeping track of bytes is when your application simply don't operate at byte level, you could be using stream-based transmissions (f.ex StreamReader) or perhaps serialization. One possibility is to use Socket class instead of TcpClient and write an inherited NetworkStream class where you override all Read/Write methods and keep track of the bytes here, no matter how that stream is used at a higher level. Combining the Socket and the custom NetworkStream and you in effect have a custom TcpClient.
 
Back
Top