c# tcp高频率向客户端广播数据延迟,1000元报酬 100C

能解决的加我qq2220099315 ,给1000元报酬
源码链接
http://pan.baidu.com/s/1czfL7o
private void Send(byte[] datas,int cmd) {

            try
            {
                    byte[] bt = Funcoins.DatagramResolver(datas, cmd);

                    TcpClient.BeginSend(bt, 0, bt.Length, SocketFlags.None,
                     new AsyncCallback(SendEnd), TcpClient);


            }
            catch
            {

            }





    }

通过tcp异步发送数据,大概每50ms向所有链接广播一共1049byte的数据,大约在有20个左右链接的时候回出现卡死或者数据延迟,
数据结构体如下:
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
[Serializable]
public struct TapAPIQuoteWhole
{
///
/// 合约
///
public TapAPIContract Contract;
///
/// 币种编号
///
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 11)]
public string CurrencyNo;
///
/// 交易状态。1,集合竞价;2,集合竞价撮合;3,连续交易;4,交易暂停;5,闭市
///

    public char TradingState;
    /// <summary>
    /// 时间戳
    /// </summary>
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 24)]
    public string DateTimeStamp;
    /// <summary>
    /// 昨收盘价
    /// </summary>
    public double QPreClosingPrice;
    /// <summary>
    /// 昨结算价
    /// </summary>

    public double QPreSettlePrice;
    /// <summary>
    ///  昨持仓量
    /// </summary>
    public UInt64 QPrePositionQty;
    /// <summary>
    /// 开盘价
    /// </summary>
    public double QOpeningPrice;
    /// <summary>
    /// 最新价
    /// </summary>
    public double QLastPrice;
    /// <summary>
    /// 最高价
    /// </summary>
    public double QHighPrice;
    /// <summary>
    /// 最低价
    /// </summary>
    public double QLowPrice;
    /// <summary>
    /// 历史最高价
    /// </summary>
    public double QHisHighPrice;
    /// <summary>
    /// 历史最低价
    /// </summary>
    public double QHisLowPrice;
    /// <summary>
    /// 涨停价
    /// </summary>
    public double QLimitUpPrice;
    /// <summary>
    ///  跌停价
    /// </summary>
    public double QLimitDownPrice;
    /// <summary>
    /// 当日总成交量
    /// </summary>
    public UInt64 QTotalQty;
    /// <summary>
    /// 当日成交金额
    /// </summary>
    public double QTotalTurnover;
    /// <summary>
    ///  持仓量
    /// </summary>
    public UInt64 QPositionQty;
    /// <summary>
    /// 均价
    /// </summary>
    public double QAveragePrice;
    /// <summary>
    /// 收盘价
    /// </summary>
    public double QClosingPrice;
    /// <summary>
    ///  结算价
    /// </summary>
    public double QSettlePrice;
    /// <summary>
    /// 最新成交量
    /// </summary>
    public UInt64 QLastQty;
    /// <summary>
    /// 买价1-21档
    /// </summary>
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)]
    public double[] QBidPrice;
    /// <summary>
    /// 买量1-21档
    /// </summary>
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)]
    public UInt64[] QBidQty;
    /// <summary>
    /// 卖价1-21档
    /// </summary>
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)]
    public double[] QAskPrice;
    /// <summary>
    /// 卖量1-21档
    /// </summary>

    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)]
    public UInt64[] QAskQty;
    /// <summary>
    ///  隐含买价
    /// </summary>

    public double QImpliedBidPrice;
    /// <summary>
    ///  隐含买量
    /// </summary>
    public UInt64 QImpliedBidQty;
    /// <summary>
    /// 隐含卖价
    /// </summary>
    public double QImpliedAskPrice;
    /// <summary>
    ///  隐含卖量
    /// </summary>
    public UInt64 QImpliedAskQty;
    /// <summary>
    /// 昨虚实度
    /// </summary>
    public double QPreDelta;
    /// <summary>
    ///  今虚实度
    /// </summary>
    public double QCurrDelta;
    /// <summary>
    /// 内盘量
    /// </summary>
    public UInt64 QInsideQty;
    /// <summary>
    /// 外盘量
    /// </summary>
    public UInt64 QOutsideQty;
    /// <summary>
    ///  换手率
    /// </summary>
    public double QTurnoverRate;
    /// <summary>
    /// 五日均量
    /// </summary>

    public UInt64 Q5DAvgQty;
    /// <summary>
    /// 市盈率
    /// </summary>
    public double QPERatio;
    /// <summary>
    /// 总市值
    /// </summary>
    public double QTotalValue;
    /// <summary>
    /// 流通市值
    /// </summary>
    public double QNegotiableValue;
    /// <summary>
    /// 持仓走势
    /// </summary>
    public UInt64 QPositionTrend;
    /// <summary>
    ///  涨速
    /// </summary>
    public double QChangeSpeed;
    /// <summary>
    /// 涨幅
    /// </summary>
    public double QChangeRate;
    /// <summary>
    /// 涨跌值
    /// </summary>
    public double QChangeValue;
    /// <summary>
    ///  振幅
    /// </summary>
    public double QSwing;
    /// <summary>
    /// 委买总量
    /// </summary>
    public UInt64 QTotalBidQty;
    /// <summary>
    ///  委卖总量
    /// </summary>
    public UInt64 QTotalAskQty;
};

2个回答

把你全部的源代码上传到百度网盘,然后才好帮你调试啊

对头,1000元算数吗?

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!