Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Professionals
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
ASP.NET 3.5 Professionals If you are an experienced ASP.NET programmer, this is the forum for your 3.5 questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Professionals section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 10th, 2009, 09:28 PM
Authorized User
 
Join Date: Jun 2009
Posts: 18
Thanks: 1
Thanked 0 Times in 0 Posts
Smile How to get the IP address of the Remoting Client on Remoting Server

Hi,everybody,
I've been working on this problem for a few days,I google search lots of code,but it didn't work.

ClientIPServerSink.cs
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Remoting.Channels;
using System.Net;
using System.Runtime.Remoting.Messaging;
using System.IO;
namespace BusinessLogicModel
{
    public class ClientIPServerSink : BaseChannelObjectWithProperties, IServerChannelSink, IChannelSinkBase
    {
        private IServerChannelSink _next;
        public ClientIPServerSink(IServerChannelSink next)
        {
            _next = next;
        }
        public void AsyncProcessResponse(IServerResponseChannelSinkStack sinkStack, Object state, IMessage msg, ITransportHeaders headers, Stream stream)
        {
        }
        public Stream GetResponseStream(IServerResponseChannelSinkStack sinkStack, Object state, IMessage msg, ITransportHeaders headers)
        {
            return null;
        }
        public System.Runtime.Remoting.Channels.ServerProcessing ProcessMessage(IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream requestStream, out IMessage responseMsg, out ITransportHeaders responseHeaders, out Stream responseStream)
        {
            if (_next != null)
            {
                IPAddress ip = requestHeaders[CommonTransportKeys.IPAddress] as IPAddress;
                Console.WriteLine(ip.ToString());
                CallContext.SetData("ClientIPAddress", ip);
                ServerProcessing spres = _next.ProcessMessage(sinkStack, requestMsg, requestHeaders, requestStream, out responseMsg, out responseHeaders, out responseStream);
                return spres;
            }
            else
            {
                responseMsg = null;
                responseHeaders = null;
                responseStream = null;
                return new ServerProcessing();
            }
        }
        public IServerChannelSink NextChannelSink
        {
            get { return _next; }
            set { _next = value; }
        }
        #region IServerChannelSink 成员
        void IServerChannelSink.AsyncProcessResponse(IServerResponseChannelSinkStack sinkStack, object state, IMessage msg, ITransportHeaders headers, Stream stream)
        {
            throw new NotImplementedException();
        }
        Stream IServerChannelSink.GetResponseStream(IServerResponseChannelSinkStack sinkStack, object state, IMessage msg, ITransportHeaders headers)
        {
            throw new NotImplementedException();
        }
        IServerChannelSink IServerChannelSink.NextChannelSink
        {
            get { throw new NotImplementedException(); }
        }
        ServerProcessing IServerChannelSink.ProcessMessage(IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream requestStream, out IMessage responseMsg, out ITransportHeaders responseHeaders, out Stream responseStream)
        {
            throw new NotImplementedException();
        }
        #endregion
        #region IChannelSinkBase 成员
        System.Collections.IDictionary IChannelSinkBase.Properties
        {
            get { throw new NotImplementedException(); }
        }
        #endregion
    }
}

ClientIPServerSinkProvider .cs
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Remoting.Channels;
using System.Collections;
namespace BusinessLogicModel
{
    public class ClientIPServerSinkProvider : IServerChannelSinkProvider
    {
        private IServerChannelSinkProvider next = null;
        public ClientIPServerSinkProvider()
        {
 
        }
        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; }
        }
        #region IServerChannelSinkProvider 成员
        IServerChannelSink IServerChannelSinkProvider.CreateSink(IChannelReceiver channel)
        {
            throw new NotImplementedException();
        }
        void IServerChannelSinkProvider.GetChannelData(IChannelDataStore channelData)
        {
            throw new NotImplementedException();
        }
        IServerChannelSinkProvider IServerChannelSinkProvider.Next
        {
            get
            {
                throw new NotImplementedException();
            }
            set
            {
                throw new NotImplementedException();
            }
        }
        #endregion
    }
}
How can I use the two segments so I'm able to get client ip address?

Anyone who can help me,please tell me? Thanks in advance!
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
.NET Remoting Client... babloo81 BOOK: Professional C#, 2nd and 3rd Editions 0 January 31st, 2006 02:31 AM
RegisterChannel on the client (.NET Remoting) DevMike BOOK: Professional C#, 2nd and 3rd Editions 1 January 25th, 2006 01:37 PM
Remoting using SOAP without web server? jacob C# 3 February 26th, 2005 11:16 AM
capture the ip address of the client ranakdinesh BOOK: Professional C#, 2nd and 3rd Editions 1 June 1st, 2004 09:31 AM



All times are GMT -4. The time now is 08:30 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.