Closed ourplan9000 closed 7 years ago
原文未添加 m_ReceiveCache.Clear();
I did a fix just now. Could you check if it works?
Already pushed to nuget, just use the version 0.8.0.11 https://www.nuget.org/packages/SuperSocket.ClientEngine/0.8.0.11
08.0.11确实可以了, 但.net 4.5使用await关键无法连127.0.0.1以上外的IP
你代码咋写的?
代码如下
client = new EasyClient
client.NewPackageReceived += client_NewPackageReceived;
client.Error += client_Error;
client.Connected += client_Connected;
client.Closed += client_Closed;
await client.ConnectAsync(ipEndPoint);
public class EasyClient<TPackageInfo> : EasyClientBase
where TPackageInfo : IPackageInfo
{
public event EventHandler<PackageEventArgs<TPackageInfo>> NewPackageReceived;
public EasyClient()
{
}
public virtual void Initialize(IReceiveFilter<TPackageInfo> receiveFilter)
{
PipeLineProcessor = new DefaultPipelineProcessor<TPackageInfo>(receiveFilter,
2 * 1024 * 1024);
}
protected override void HandlePackage(IPackageInfo package)
{
var handler = NewPackageReceived;
if (handler == null)
return;
handler(this, new PackageEventArgs<TPackageInfo>((TPackageInfo)package));
}
/// <summary>
/// 析构函数释放连接
/// </summary>
~EasyClient()
{
if (this.IsConnected)
this.Close();
}
}
}
是不是被UI线程锁住了? await client.ConnectAsync(ipEndPoint).ConfigureAwait(false);
用你提供的代码也不行,不用await也不行
反正127.0.0.1以外的ip连不了
换成4.0的就可以
if (m_MaxPackageLength > 0)