IPv4 remote address in WCF
c#, tcp, wcf
Solution
No, I don't think so. You basically just read out a property set by the client at the time of the call. Your only option would be to instruct the client (through some config) to use IPv4 instead of IPv6 at all times (i.e. turn off IPv6 all together).
I'm not aware of any WCF setting to enforce that - you'd have to dig into the network stack and see if there's any way to make it use IPv4 addresses instead of IPv6.
Problem
Related to How to get the IP address of a WCF remote endpoint? I am using this code to retrieve the remote IP address when a workflow method is invoked: ``` private static string GetRemoteIP() { var oc = OperationContext.Current; var mp = oc.IncomingMessageProperties; var remp = mp[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty; return remp == null ? "(unknown)" : remp.Address; } ``` However, the address I get back is "::1". I don't want the IPv6 address, I want the IPv4 one (127.0.0.1) - any way of forcing this?