public MySocket(string remote_ip, PortEnum remote_port) { _syncContext = Documento.GetIstance().SyncContext; _remoteAddress = remote_ip + ":" + remote_port; IPHostEntry hostEntry = Dns.GetHostEntry(remote_ip); foreach (IPAddress remote_address in hostEntry.AddressList) { IPEndPoint ipe = new IPEndPoint(remote_address, (int)remote_port); _socket = new Socket(ipe.AddressFamily, SocketType.Stream, ProtocolType.Tcp); _remoteAddress = remote_address.ToString(); try { _socket.Connect(ipe); } catch { continue; } if (_socket.Connected) { break; } } if (!_socket.Connected) { throw new SocketException(); } else { InitMySocket(); } }
public MyServerSocket(string local_ip, PortEnum local_port) { _syncContext = Documento.GetIstance().SyncContext; IPHostEntry hostEntry = Dns.GetHostEntry(local_ip); IPEndPoint ipe = new IPEndPoint(hostEntry.AddressList[0], (int)local_port); _socket = new Socket(ipe.AddressFamily, SocketType.Stream, ProtocolType.Tcp); _socket.Bind(ipe); InitMyServerSocket(); }
/// <summary> /// Enumerate all ports /// </summary> public int EnumPorts(out IEnumDebugPorts2 ppEnum) { DLog.Debug(DContext.VSDebuggerComCall, "DebugPortSupplier.EnumPorts"); ppEnum = new PortEnum(ports.Values.Cast<IDebugPort2>().ToArray()); return VSConstants.S_OK; }