private void r4_names(TcpClient s, OtpInputStream ibuf) { try { if (traceLevel >= traceThreshold) { log.Debug("<- NAMES(r4) "); } OtpOutputStream obuf = new OtpOutputStream(); obuf.write4BE(EpmdPort.get()); lock (portmap) { foreach (KeyValuePair <string, OtpPublishedNode> pair in portmap) { OtpPublishedNode node = pair.Value; string info = String.Format("name {0} at port {1}\n", node.Alive, node.Port); byte[] bytes = Encoding.GetEncoding("iso-8859-1").GetBytes(info); obuf.writeN(bytes); } } obuf.WriteTo(s.GetStream()); } catch (IOException) { if (traceLevel >= traceThreshold) { log.Debug("<- (no response)"); } throw new IOException("Request not responding"); } return; }
private void r4_port(TcpClient s, OtpInputStream ibuf) { try { int len = (int)(ibuf.Length - 1); byte[] alive = new byte[len]; ibuf.readN(alive); String name = OtpErlangString.newString(alive); OtpPublishedNode node = null; if (traceLevel >= traceThreshold) { log.Debug("<- PORT (r4) " + name); } lock (portmap) { if (portmap.ContainsKey(name)) { node = portmap[name]; } } OtpOutputStream obuf = new OtpOutputStream(); if (node != null) { obuf.write1(port4resp); obuf.write1(0); obuf.write2BE(node.Port); obuf.write1(node.Type); obuf.write1(node.Proto); obuf.write2BE(node.DistHigh); obuf.write2BE(node.DistLow); obuf.write2BE(len); obuf.writeN(alive); obuf.write2BE(0); } else { obuf.write1(port4resp); obuf.write1(1); } obuf.WriteTo(s.GetStream()); } catch (IOException) { if (traceLevel >= traceThreshold) { log.Debug("<- (no response)"); } throw new IOException("Request not responding"); } return; }
private void r4_publish(TcpClient s, OtpInputStream ibuf) { try { int port = ibuf.read2BE(); int type = ibuf.read1(); int proto = ibuf.read1(); int distHigh = ibuf.read2BE(); int distLow = ibuf.read2BE(); int len = ibuf.read2BE(); byte[] alive = new byte[len]; ibuf.readN(alive); int elen = ibuf.read2BE(); byte[] extra = new byte[elen]; ibuf.readN(extra); String name = OtpErlangString.newString(alive); OtpPublishedNode node = new OtpPublishedNode(name); node.Type = type; node.DistHigh = distHigh; node.DistLow = distLow; node.Proto = proto; node.Port = port; if (traceLevel >= traceThreshold) { log.Debug("<- PUBLISH (r4) " + name + " port=" + node.Port); } OtpOutputStream obuf = new OtpOutputStream(); obuf.write1(publish4resp); obuf.write1(0); obuf.write2BE(epmd.Creation); obuf.WriteTo(s.GetStream()); lock (portmap) { portmap.Add(name, node); } publishedPort.Add(name); } catch (IOException) { if (traceLevel >= traceThreshold) { log.Debug("<- (no response)"); } throw new IOException("Request not responding"); } return; }
private void r4_publish(TcpClient s, OtpInputStream ibuf) { try { int port = ibuf.read2BE(); int type = ibuf.read1(); int proto = ibuf.read1(); int distHigh = ibuf.read2BE(); int distLow = ibuf.read2BE(); int len = ibuf.read2BE(); byte[] alive = new byte[len]; ibuf.readN(alive); int elen = ibuf.read2BE(); byte[] extra = new byte[elen]; ibuf.readN(extra); String name = OtpErlangString.newString(alive); OtpPublishedNode node = new OtpPublishedNode(name); node.Type = type; node.DistHigh = distHigh; node.DistLow = distLow; node.Proto = proto; node.Port = port; if (traceLevel >= traceThreshold) { log.Debug("<- PUBLISH (r4) " + name + " port=" + node.Port); } OtpOutputStream obuf = new OtpOutputStream(); obuf.write1(publish4resp); obuf.write1(0); obuf.write2BE(epmd.Creation); obuf.WriteTo(s.GetStream()); lock (portmap) { portmap.Add(name, node); } publishedPort.Add(name); } catch (IOException) { if (traceLevel >= traceThreshold) { log.Debug("<- (no response)"); } throw new IOException("Request not responding"); } return; }