public override EndPoint Create(SocketAddress socketAddress) { /* * Should also check this */ int addr = (int)AddressFamily.Unix; if (socketAddress [0] != (addr & 0xFF)) { throw new ArgumentException("socketAddress is not a unix socket address."); } if (socketAddress [1] != ((addr & 0xFF00) >> 8)) { throw new ArgumentException("socketAddress is not a unix socket address."); } if (socketAddress.Size == 2) { // Empty filename. // Probably from RemoteEndPoint which on linux does not return the file name. UnixEndPoint uep = new UnixEndPoint("a"); uep.filename = ""; return(uep); } int size = socketAddress.Size - 2; byte[] bytes = new byte[size]; for (int i = 0; i < bytes.Length; i++) { bytes[i] = socketAddress[i + 2]; // There may be junk after the null terminator, so ignore it all. if (bytes[i] == 0) { size = i; break; } } string name = Encoding.UTF8.GetString(bytes, 0, size); return(new UnixEndPoint(name)); }
public UnixDomainSocketClient(string ipcPath) { _ipcPath = ipcPath; _unixEndPoint = new UnixEndPoint(_ipcPath); }