39 lines
948 B
C#
39 lines
948 B
C#
using System;
|
|
using System.Configuration;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
namespace SocketTransfer.SDK
|
|
{
|
|
public class SocketBase : Socket
|
|
{
|
|
public static Encoding GetEncoding()
|
|
{
|
|
string value = ConfigurationManager.AppSettings.Get(typeof(SocketBase).FullName + ".Encoding");
|
|
|
|
if (!string.IsNullOrEmpty(value) && Encoding.GetEncoding(value) != null)
|
|
{
|
|
return Encoding.GetEncoding(value);
|
|
}
|
|
|
|
return Encoding.GetEncoding("GBK");
|
|
}
|
|
|
|
protected SocketBase(byte[] source, params int[] phases) :
|
|
base(source, GetEncoding(), phases)
|
|
{
|
|
|
|
}
|
|
|
|
public override bool Valid()
|
|
{
|
|
if (!base.Valid() && Phases.Length < 2 && Phases[1] != 2)
|
|
{
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
}
|