private async void HandleConnectionAsync(IOtpTransport socket) { Logger.Info($"[OtpEpmd] connected {socket}"); List <string> publishedNodes = new List <string>(); try { while (true) { var ibuf = await ReadRequestAsync(socket); int request = ibuf.Read1(); // This request retains the connection if (request == ALIVE2_REQ) { publishedNodes.Add(await Publish_R4(socket, ibuf)); continue; } // These requests terminate the connection if (request == stopReq) { } else if (request == port4req) { await Port_R4(socket, ibuf); } else if (request == names4req) { await Names_R4(socket); } else { Logger.Info($"[OtpEpmd] Unknown request (request={request}, length={ibuf.Length}) from {socket}"); } break; } } catch (Exception e) { Logger.Error($"[OtpEpmd] socket {socket} error {e}"); } Logger.Info($"[OtpEpmd] closing {socket}"); OtpTransport.Close(socket); foreach (var name in publishedNodes) { portmap.TryRemove(name, out _); } }
/** * Unregister the server node's name and port number from the Erlang port * mapper, thus preventing any new connections from remote nodes. */ public void UnPublishPort() { if (Epmd == null) { return; } // Unregister OtpEpmd.UnPublishPort(this); // Close and ignore errors OtpTransport.Close(Epmd); Epmd = null; }
/** * Close the connection to the remote node. */ public virtual void Close() { Stop(); Connected = false; lock (objRead) { if (socket != null) { if (TraceLevel >= TraceCTRL) { Logger.Debug($"-> CLOSE {socket}"); } OtpTransport.Close(socket); socket = null; } } }
public void Close() => OtpTransport.Close(socket);
public void Stop() { stopping = true; OtpTransport.Close(listen); }