public override void Run() { try { DomainSocket client = DomainSocket.Connect(TestPath); OutputStream clientOutputStream = client.GetOutputStream(); InputStream clientInputStream = client.GetInputStream(); clientOutputStream.Write(clientMsg1); DomainSocket domainConn = (DomainSocket)client; byte[] in1 = new byte[serverMsg1.Length]; FileInputStream[] recvFis = new FileInputStream[passedFds.Length]; int r = domainConn.RecvFileInputStreams(recvFis, in1, 0, in1.Length - 1); Assert.True(r > 0); IOUtils.ReadFully(clientInputStream, in1, r, in1.Length - r); Assert.True(Arrays.Equals(serverMsg1, in1)); for (int i = 0; i < passedFds.Length; i++) { NUnit.Framework.Assert.IsNotNull(recvFis[i]); passedFiles[i].CheckInputStream(recvFis[i]); } foreach (FileInputStream fis in recvFis) { fis.Close(); } client.Close(); } catch (System.Exception e) { threadResults.AddItem(e); } threadResults.AddItem(new TestDomainSocket.Success()); }
public override void Run() { DomainSocket conn = null; try { conn = preConnectedSockets != null ? preConnectedSockets[0] : serv.Accept(); byte[] in1 = new byte[clientMsg1.Length]; TestDomainSocket.ReadStrategy reader = System.Activator.CreateInstance(readStrategyClass ); reader.Init(conn); reader.ReadFully(in1, 0, in1.Length); Assert.True(Arrays.Equals(clientMsg1, in1)); TestDomainSocket.WriteStrategy writer = System.Activator.CreateInstance(writeStrategyClass ); writer.Init(conn); writer.Write(serverMsg1); InputStream connInputStream = conn.GetInputStream(); int in2 = connInputStream.Read(); Assert.Equal((int)clientMsg2, in2); conn.Close(); } catch (Exception e) { threadResults.AddItem(e); NUnit.Framework.Assert.Fail(e.Message); } threadResults.AddItem(new TestDomainSocket.Success()); }
public Void Call() { DomainSocket serverConn = null; try { serverConn = serv.Accept(); byte[] buf = new byte[100]; for (int i = 0; i < buf.Length; i++) { buf[i] = 0; } if (closeDuringWrite) { try { while (true) { serverConn.GetOutputStream().Write(buf); } } catch (IOException) { } } else { do { }while (serverConn.GetInputStream().Read(buf, 0, buf.Length) != -1); } } catch (IOException e) { throw new RuntimeException("unexpected IOException", e); } finally { IOUtils.Cleanup(DomainSocket.Log, serverConn); } return(null); }
public override void Run() { DomainSocket conn = null; try { conn = serv.Accept(); byte[] in1 = new byte[clientMsg1.Length]; InputStream connInputStream = conn.GetInputStream(); IOUtils.ReadFully(connInputStream, in1, 0, in1.Length); Assert.True(Arrays.Equals(clientMsg1, in1)); DomainSocket domainConn = (DomainSocket)conn; domainConn.SendFileDescriptors(passedFds, serverMsg1, 0, serverMsg1.Length); conn.Close(); } catch (System.Exception e) { threadResults.AddItem(e); NUnit.Framework.Assert.Fail(e.Message); } threadResults.AddItem(new TestDomainSocket.Success()); }
public virtual bool Handle(DomainSocket sock) { System.Diagnostics.Debug.Assert((this._enclosing.Lock.IsHeldByCurrentThread())); try { this._enclosing.kicked = false; if (DomainSocketWatcher.Log.IsTraceEnabled()) { DomainSocketWatcher.Log.Trace(this + ": NotificationHandler: doing a read on " + sock.fd); } if (sock.GetInputStream().Read() == -1) { if (DomainSocketWatcher.Log.IsTraceEnabled()) { DomainSocketWatcher.Log.Trace(this + ": NotificationHandler: got EOF on " + sock. fd); } throw new EOFException(); } if (DomainSocketWatcher.Log.IsTraceEnabled()) { DomainSocketWatcher.Log.Trace(this + ": NotificationHandler: read succeeded on " + sock.fd); } return(false); } catch (IOException) { if (DomainSocketWatcher.Log.IsTraceEnabled()) { DomainSocketWatcher.Log.Trace(this + ": NotificationHandler: setting closed to " + "true for " + sock.fd); } this._enclosing.closed = true; return(true); } }
/// <exception cref="System.IO.IOException"/> public override void Init(DomainSocket s) { ins = s.GetInputStream(); }