public static VirtualMachine LaunchInternal (ITargetProcess p, ProcessStartInfo info, Socket socket) { Socket accepted = null; try { accepted = socket.Accept (); } catch (Exception) { throw; } Connection conn = new TcpConnection (accepted); VirtualMachine vm = new VirtualMachine (p, conn); if (info.RedirectStandardOutput) vm.StandardOutput = p.StandardOutput; if (info.RedirectStandardError) vm.StandardError = p.StandardError; conn.EventHandler = new EventHandler (vm); vm.connect (); return vm; }
public static VirtualMachine ConnectInternal (Socket dbg_sock, Socket con_sock, IPEndPoint dbg_ep, IPEndPoint con_ep) { if (con_sock != null) { try { con_sock.Connect (con_ep); } catch (Exception) { try { dbg_sock.Close (); } catch {} throw; } } try { dbg_sock.Connect (dbg_ep); } catch (Exception) { if (con_sock != null) { try { con_sock.Close (); } catch {} } throw; } Connection transport = new TcpConnection (dbg_sock); StreamReader console = con_sock != null? new StreamReader (new NetworkStream (con_sock)) : null; return Connect (transport, console, null); }
public static VirtualMachine ListenInternal (Socket dbg_sock, Socket con_sock) { Socket con_acc = null; Socket dbg_acc = null; if (con_sock != null) { try { con_acc = con_sock.Accept (); } catch (Exception) { try { dbg_sock.Close (); } catch {} throw; } } try { dbg_acc = dbg_sock.Accept (); } catch (Exception) { if (con_sock != null) { try { con_sock.Close (); con_acc.Close (); } catch {} } throw; } if (con_sock != null) { if (con_sock.Connected) con_sock.Disconnect (false); con_sock.Close (); } if (dbg_sock.Connected) dbg_sock.Disconnect (false); dbg_sock.Close (); Connection transport = new TcpConnection (dbg_acc); StreamReader console = con_acc != null? new StreamReader (new NetworkStream (con_acc)) : null; return Connect (transport, console, null); }