本文整理汇总了C#中MySql.Data.MySqlClient.MySqlStream.Flush方法的典型用法代码示例。如果您正苦于以下问题:C# MySqlStream.Flush方法的具体用法?C# MySqlStream.Flush怎么用?C# MySqlStream.Flush使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MySql.Data.MySqlClient.MySqlStream
的用法示例。
在下文中一共展示了MySqlStream.Flush方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Open
public override void Open()
{
base.Open();
// connect to one of our specified hosts
try
{
#if !CF
if (Settings.ConnectionProtocol == MySqlConnectionProtocol.SharedMemory)
{
SharedMemoryStream str = new SharedMemoryStream(Settings.SharedMemoryName);
str.Open(Settings.ConnectionTimeout);
baseStream = str;
}
else
{
#endif
string pipeName = Settings.PipeName;
if (Settings.ConnectionProtocol != MySqlConnectionProtocol.NamedPipe)
pipeName = null;
StreamCreator sc = new StreamCreator(Settings.Server, Settings.Port, pipeName);
baseStream = sc.GetStream(Settings.ConnectionTimeout);
#if !CF
}
#endif
if (baseStream == null)
throw new Exception();
}
catch (Exception ex)
{
throw new MySqlException(Resources.UnableToConnectToHost,
(int) MySqlErrorCode.UnableToConnectToHost, ex);
}
if (baseStream == null)
throw new MySqlException("Unable to connect to any of the specified MySQL hosts");
int maxSinglePacket = 255*255*255;
stream = new MySqlStream(baseStream, encoding, false);
// read off the welcome packet and parse out it's values
stream.OpenPacket();
protocol = stream.ReadByte();
string versionString = stream.ReadString();
version = DBVersion.Parse(versionString);
threadId = stream.ReadInteger(4);
encryptionSeed = stream.ReadString();
if (version.isAtLeast(4, 0, 8))
maxSinglePacket = (256*256*256) - 1;
// read in Server capabilities if they are provided
serverCaps = 0;
if (stream.HasMoreData)
serverCaps = (ClientFlags) stream.ReadInteger(2);
if (version.isAtLeast(4, 1, 1))
{
/* New protocol with 16 bytes to describe server characteristics */
serverCharSetIndex = stream.ReadInteger(1);
serverStatus = (ServerStatusFlags) stream.ReadInteger(2);
stream.SkipBytes(13);
string seedPart2 = stream.ReadString();
encryptionSeed += seedPart2;
}
// based on our settings, set our connection flags
SetConnectionFlags();
stream.StartOutput(0, false);
stream.WriteInteger((int) connectionFlags,
version.isAtLeast(4, 1, 0) ? 4 : 2);
#if !CF
if (connectionString.UseSSL && (serverCaps & ClientFlags.SSL) != 0)
{
stream.Flush();
StartSSL();
stream.StartOutput(0, false);
stream.WriteInteger((int) connectionFlags,
version.isAtLeast(4, 1, 0) ? 4 : 2);
}
#endif
stream.WriteInteger(maxSinglePacket,
version.isAtLeast(4, 1, 0) ? 4 : 3);
if (version.isAtLeast(4, 1, 1))
{
stream.WriteByte(8);
stream.Write(new byte[23]);
}
Authenticate();
// if we are using compression, then we use our CompressedStream class
// to hide the ugliness of managing the compression
if ((connectionFlags & ClientFlags.COMPRESS) != 0)
//.........这里部分代码省略.........