最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
在Remoting Server上取得Remoting Client的IP地址
时间:2022-07-02 23:33:07 编辑:袖梨 来源:一聚教程网
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 is available in the Transport Headers of the incoming message. After retrieving the IP address in the Sink, we save the IP address to the CallContext, so that it will be available later in the code execution path as well. 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; }
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; }
相关文章
- 《弓箭传说2》新手玩法介绍 01-16
- 《地下城与勇士:起源》断桥烟雨多买多送活动内容一览 01-16
- 《差不多高手》醉拳龙技能特点分享 01-16
- 《鬼谷八荒》毕方尾羽解除限制道具推荐 01-16
- 《地下城与勇士:起源》阿拉德首次迎新春活动内容一览 01-16
- 《差不多高手》情圣技能特点分享 01-16