getting ip in service using tcp connection [Archive] - C Board

PDA

View Full Version : getting ip in service using tcp connection


RevengerPT
03-24-2008, 08:20 AM
Hi there. I'm building a small chat in which there is a main server that hosts a service, and there are many clients. Each client hosts a service too, so it can get any messages sent by other clients, through a call done by the server.

But I have a little problem. I need to know every client IP. I searched a lot, and I found it to be easier using HttpChannel, where I can just use something like:

string clientAddress = HttpContext.Current.Request.UserHostAddress;

This is great as I can do it inside the service.

But I'm using a TcpChannel as a connection.


namespace Server
{
class Server
{
static void Main(string[] args)
{
TcpChannel channel = new TcpChannel(8086);
ChannelServices.RegisterChannel(channel, true);

RemotingConfiguration.RegisterWellKnownServiceType (
typeof(ServerService),
"server",
WellKnownObjectMode.Singleton);

System.Console.WriteLine("press <enter> to quit...");

System.Console.ReadLine();
}
}
}


How can I, inside of the ServerService, get the client IP?

Thanks in advance.

My best regards.