Mono.Debugger.Soft.VirtualMachineManager.ListenInternal C# (CSharp) Method

ListenInternal() public static method

public static ListenInternal ( Socket dbg_sock, Socket con_sock ) : VirtualMachine
dbg_sock Socket
con_sock Socket
return VirtualMachine
		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 conn = new Connection (dbg_acc);

			VirtualMachine vm = new VirtualMachine (null, conn);

			if (con_acc != null) {
				vm.StandardOutput = new StreamReader (new NetworkStream (con_acc));
				vm.StandardError = null;
			}

			conn.EventHandler = new EventHandler (vm);

			vm.connect ();

			return vm;
		}