Obtaining the IP address of remoting client on the remoting server
Source: Internet
Author: User
In short, the Remoting Server can make use of Sink and Sink Provider to retrieve the IP address of the incoming request. The IP address was available in the transport Headers of the incoming message. After retrieving the IP addresses in the Sink, we save the IP addresses to the CallContext and so it would be available later In the code execution path as. The followings are some background information regarding the topics:
Sinks and Sink chains
Http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconsinkssinkchains.asp
Using CallContext
Http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconusingcallcontext.asp
Code modified from the sample by Ingo Rammer, author of "Advanced. Net Remoting":
Using System;
Using System.Collections;
Using System.IO;
Using System.Runtime.Remoting;
Using System.Runtime.Remoting.Messaging;
Using System.Runtime.Remoting.Channels;
Using System.Threading;
Using System.Net;
Namespace Classlibremotingipsink
{
public class Clientipserversinkprovider:iserverchannelsinkprovider
{
Private IServerChannelSinkProvider next = null;
Public Clientipserversinkprovider (IDictionary properties, ICollection Providerdata)
{
}
public void Getchanneldata (Ichanneldatastore channeldata)
{
}
Public IServerChannelSink CreateSink (IChannelReceiver channel)
{
IServerChannelSink nextsink = null;
if (next!= null)
{
Nextsink = Next. CreateSink (channel);
}
return new Clientipserversink (Nextsink);
}
Public IServerChannelSinkProvider Next
{
get {return next;}
set {next = value;}
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.