Delphi之udt单元
巡山小妖精
646次浏览
2020年07月29日 19:15
最佳经验
本文由作者推荐
open是什么意思-弯弯的什么
Copyright (c) 2001 - 2007, The Board of Trustees of the University of Illinois.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the
above copyright notice, this list of conditions
and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the University of Illinois
nor the names of its contributors may be used to
endorse or promote products derived from this
software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************}
{*****************************************************************************
written by
Yunhong Gu, last updated 12/02/2007
translated by
Zhengcheng Zhang, last updated 10/10/2008
*****************************************************************************}
Unit udt;
Interface
{$$INCLUDE }
Uses
SysUtils, Classes,
{$$IFDEF DELPHI}
Windows, Winsock, JwaWinsock2, JwaWS2tcpip,
{$$ENDIF}
{$$IFDEF KYLIX}
Libc,
{$$ENDIF}
StrUtils
;
Const
ERROR = -1;
INVALID_SOCK = -1;
{$$IFDEF DELPHI}
UDTLIB = '';
{$$ENDIF}
{$$IFDEF KYLIX}
UDTLIB = '';
{$$ENDIF}
Type
{$$IFDEF KYLIX}
pAddrInfo = pAddressInfo;
{$$ENDIF}
UDTSOCKET = Integer;
pInteger = ^Integer;
pUDTSOCKET = ^UDTSOCKET;
UDTOpt = (
UDT_MSS, // the Maximum Transfer Unit
UDT_SNDSYN, // if sending is blocking
UDT_RCVSYN, // if receiving is blocking
UDT_CC, // custom congestion control algorithm
UDT_FC,tt // Flight flag size (window size)
UDT_SNDBUF, // maximum buffer in sending queue
UDT_RCVBUF, // UDT receiving buffer size
UDT_LINGER, // waiting for unsent data when
closing
UDP_SNDBUF, // UDP sending buffer size
UDP_RCVBUF, // UDP receiving buffer size
UDT_MAXMSG, // maximum datagram message size
UDT_MSGTTL, // time-to-live of a datagram message
UDT_RENDEZVOUS, // rendezvous connection mode
UDT_SNDTIMEO, // send() timeout
UDT_RCVTIMEO, // recv() timeout
UDT_REUSEADDRt // reuse an existing port or create a new one
);
CPerfMon = Record
// global measurements
msTimeStamp: Int64; // time since the UDT entity is started, in milliseconds
pktSentTotal: Int64; // total number of sent data packets, including retransmissions
pktRecvTotal: Int64; // total number of received packets
pktSndLossTotal: Integer; // total number of lost packets (sender side)
pktRcvLossTotal: Integer; // total number of lost packets (receiver side)
pktRetransTotal: Integer; // total number of retransmitted packets
pktSentACKTotal: Integer; // total number of sent ACK packets
pktRecvACKTotal: Integer; // total number of received ACK packets
pktSentNAKTotal: Integer; // total number of sent NAK packets
pktRecvNAKTotal: Integer; // total number of received NAK packets
// local measurements
pktSent: Int64; // number of sent data packets, including retransmissions
pktRecv: Int64; // number of received packets
pktSndLoss: Integer; // number of lost packets (sender side)
pktRcvLoss: Integer; // number of lost packets (receiverer side)
pktRetrans: Integer; // number of retransmitted packets
pktSentACK: Integer; // number of sent ACK packets
pktRecvACK: Integer; // number of received ACK packets
pktSentNAK: Integer; // number of sent NAK packets
pktRecvNAK: Integer; // number of received NAK packets
mbpsSendRate: Double; // sending rate in Mb/s
mbpsRecvRate: Double; // receiving rate in Mb/s
// instant measurements
usPktSndPeriod: Double; // packet sending period, in microseconds
pktFlowWindow: Integer; // flow window size, in number of packets
pktCongestionWindow: Integer; // congestion window size, in number of packets
pktFlightSize: Integer; // number of packets on flight
msRTT: Double; // RTT, in milliseconds
mbpsBandwidth: Double; // estimated bandwidth, in Mb/s
byteAvailSndBuf: Integer; // available UDT sender buffer size
byteAvailRcvBuf: Integer; // available UDT receiver buffer size
End;
timeval = Record
tv_sec: LongInt;
tv_usec: LongInt;