remoting - information about the client. c#

≡放荡痞女 提交于 2019-12-23 12:25:24

问题


Is it possible to find out / get some information about the connecting client when using remoting on .net 2.0? I like to know get some information about the connecting client on the server side, so I can act accordingly? This is a small and very local application that Never will have more then max 10 simultaneously connecting/requesting clients.

pass client reference in each function? (or some identifier)? I could do it this way, but I would prefer to just get the information from the request/connecting client. Ip-address or similar would be nice.

Regards


回答1:


Take a look at the answer I provided for a similar question:

Identifying the client during a .NET remoting invocation (Answer)




回答2:


This question might have the answer you're looking for.

I stripped out the parts that probably don't matter to you and left the part that actually grabs the IPAddress.

public ServerProcessing ProcessMessage(IServerChannelSinkStack sinkStack, 
    IMessage requestmessage, ITransportHeaders requestHeaders, 
    System.IO.Stream requestStream, out IMessage responseMessage, 
    out ITransportHeaders responseHeaders, out System.IO.Stream responseStream)
{
    // Get the IP address and add it to the call context.
    IPAddress ipAddr = (IPAddress)requestHeaders[CommonTransportKeys.IPAddress];
}



回答3:


This question shows the apparent format of a URI, i.e. the URI property of the ObjRef you get from RemotingServices.GetObjRefForProxy when you pass it a remote object. The string between the first two slashes is a per-process GUID, which uniquely identifies the client from the perspective of the local program.

In my case, I just needed some way to identify the client, not its IP address (which wouldn't be valid with a non-TCP channel anyway), so this worked for me.



来源:https://stackoverflow.com/questions/950020/remoting-information-about-the-client-c-sharp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!