/// <exception cref="System.IO.IOException"></exception> protected internal override void DoConnect() { SmbComNegotiateResponse resp = new SmbComNegotiateResponse(Server); try { Negotiate(Port, resp); } catch (ConnectException) { Port = (Port == -1 || Port == SmbConstants.DefaultPort) ? 139 : SmbConstants.DefaultPort; Negotiate(Port, resp); } if (resp.DialectIndex > 10) { throw new SmbException("This client does not support the negotiated dialect."); } if ((Server.Capabilities & SmbConstants.CapExtendedSecurity) != SmbConstants.CapExtendedSecurity && Server .EncryptionKeyLength != 8 && SmbConstants.LmCompatibility == 0) { throw new SmbException("Unexpected encryption key length: " + Server.EncryptionKeyLength ); } TconHostName = Address.GetHostName(); if (Server.SignaturesRequired || (Server.SignaturesEnabled && SmbConstants.Signpref)) { Flags2 |= SmbConstants.Flags2SecuritySignatures; } else { Flags2 &= 0xFFFF ^ SmbConstants.Flags2SecuritySignatures; } MaxMpxCount = Math.Min(MaxMpxCount, Server.MaxMpxCount); if (MaxMpxCount < 1) { MaxMpxCount = 1; } SndBufSize = Math.Min(SndBufSize, Server.MaxBufferSize); Capabilities &= Server.Capabilities; if ((Server.Capabilities & SmbConstants.CapExtendedSecurity) == SmbConstants.CapExtendedSecurity) { Capabilities |= SmbConstants.CapExtendedSecurity; } // & doesn't copy high bit if ((Capabilities & SmbConstants.CapUnicode) == 0) { // server doesn't want unicode if (SmbConstants.ForceUnicode) { Capabilities |= SmbConstants.CapUnicode; } else { UseUnicode = false; Flags2 &= 0xFFFF ^ SmbConstants.Flags2Unicode; } } }