/trunk/Common/Overbyte ICS 7/OverbyteIcsWSocket.pas
Pascal | 13101 lines | 8520 code | 1213 blank | 3368 comment | 953 complexity | 18a1064fb08682cabeaaa7b92ee1e260 MD5 | raw file
Possible License(s): MIT, LGPL-2.0, LGPL-3.0
Large files files are truncated, but you can click here to view the full file
- {*_* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
-
- Author: François PIETTE
- Description: TWSocket class encapsulate the Windows Socket paradigm
- Creation: April 1996
- Version: 7.47
- EMail: francois.piette@overbyte.be http://www.overbyte.be
- Support: Use the mailing list twsocket@elists.org
- Follow "support" link at http://www.overbyte.be for subscription.
- Legal issues: Copyright (C) 1996-2010 by François PIETTE
- Rue de Grady 24, 4053 Embourg, Belgium. Fax: +32-4-365.74.56
- <francois.piette@overbyte.be>
- SSL implementation includes code written by Arno Garrels,
- Berlin, Germany, contact: <arno.garrels@gmx.de>
-
- This software is provided 'as-is', without any express or
- implied warranty. In no event will the author be held liable
- for any damages arising from the use of this software.
-
- Permission is granted to anyone to use this software for any
- purpose, including commercial applications, and to alter it
- and redistribute it freely, subject to the following
- restrictions:
-
- 1. The origin of this software must not be misrepresented,
- you must not claim that you wrote the original software.
- If you use this software in a product, an acknowledgment
- in the product documentation would be appreciated but is
- not required.
-
- 2. Altered source versions must be plainly marked as such, and
- must not be misrepresented as being the original software.
-
- 3. This notice may not be removed or altered from any source
- distribution.
-
- 4. You must register this software by sending a picture postcard
- to the author. Use a nice stamp and mention your name, street
- address, EMail address and any comment you like to say.
-
- History:
- If not otherwise noted, changes are by Francois Piette
- Jul 18, 1996 Move all low level socket to winsock to be Delphi 2.x compatible
- Sep 18, 1996 Use structured exception for handling errors
- Sep 19, 1996 Check csDestroying before invoking event handler
- Nov 04, 1996 Better error handling
- Jan 31, 1997 Changed property assignation for Addr, Port and Proto
- Added notification handler
- Feb 14, 1997 Corrected bug in property assignation for Addr, Port and Proto
- Mar 26, 1997 Make UDP protocol work correctly
- Enable UDP broadcasting by using addr 255.255.255.255
- Apr 1, 1997 Added class function when independent of any open socket
- Moved InitData as global
- Added ReceivedFrom function
- Added ResolveHost function
- Jul 22, 1997 Adapted to Delphi 3 which has a modified winsock.accept
- Aug 13, 1997 'sin' member made public
- Aug 24, 1997 Create the only help
- Makes writing HSocket the same as calling Dup.
- Sep 5, 1997 Version 2.01, added WinsockInfo function
- Sep 21, 1997 Version 2.02, make it really thread safe
- created global WSocketVersion
- Sep 25, 1997 Version 2.04, port to C++Builder
- Sep 27, 1997 Version 2.05. All class methods converted to global
- procedure or function because C++Builder do not like
- class method very much.
- Old class method New global function
- ---------------- -------------------
- WinsockInfo WinsockInfo
- SocketErrorDesc WSocketErrorDesc
- GetHostByAddr WSocketGetHostByAddr
- GetHostByName WSocketGetHostByName
- ResolveHost WSocketResolveHost
- HostName LocalHostName
- Oct 02, 1997 V2.06 Added a check in destructor to avoid calling WSACleanup at
- design time which crashes the excellent Eagle Software CDK.
- Oct 16, 1997 V2.07 Added PortNum property with numeric value for Port.
- Added RcvdCount property to return the number of
- characters received in the buffer but not read yet. Do not
- confuse with ReadCount which returns the number of chars
- already received.
- Added a check for FWait assignation in front of ReadLine
- Prefixed each TSocketState value by 'ws' to avoid name conflict.
- Moved FHSocket member to private section because the property
- HSocket does the right job.
- Added a check for state closed when changing Port, Proto and Addr.
- Oct 22, 1997 V2.08 Added Flush method (asked by john@nexnix.co.uk) and
- FlushTimeout property (default to 60 seconds).
- Oct 22, 1997 V2.09 Added SendFlags property to enable sending in or out of
- band data (normal or urgent, see RFC-1122)
- Oct 28, 1997 V2.10 Added an OnLineTooLong event and code to handle the case
- where ReadLine has been called and the buffer overflowed (line
- long)
- Oct 29, 1997 V2.11 Added DnsLookup functionnality (DnsLookup method, DnsResult
- property and DnsLookupDone event).
- Calling the connect method with a hostname work well except that
- it could block for a long period (ie: 2 minutes) if DNS do not
- respond. Calling the connect method with a numeric IP address will
- never block. So you can call DnsLookup to start hostname
- resolution in the background, after some time you evenutually
- receive the OnDnsLookupDone event. The copy the DnsResult property
- to the Addr property and call connect.
- Oct 30, 1997 V2.12 added a check in DnsLookup to handel numeric IP which do
- not require any lookup. The numeric IP is treated immediately
- and immediately trigger the DnsLookupDone event.
- I modified the code to be compatible with Delphi 1.
- Oct 31, 1997 V2.13 added CancelDnsLookup procedure.
- Nov 09, 1997 V2.14 add LocalIPList function to get the list of local IP
- addresses (you have two IP addresses when connected to a LAN
- and an ISP).
- Nov 11, 1997 V2.15 Made TCustomWSocket with virtual functions. This will
- allow to easily descend a new component from TCustomWSocket.
- Make ReadLine stop when the connection is broken.
- Nov 12, 1997 V2.16 Corrected bug (Justin Yunke <yunke@productivity.org>)
- in LocalIPList: phe should be checked for nil.
- Nov 18, 1997 Added ReceiveStr function (Suggested by FLDKNHA@danisco.com)
- Nov 30, 1997 V2.18 Added a call to OnDnsLookupDone when canceling.
- Dec 04, 1997 V2.19 Added LocalPort property and SessionConnected event
- for UDP socket.
- V2.20 Modified MessageLoop and ProcessMessages to process not
- only the socket messages, but all messages (necessary if the
- thread has several TWSocket for example).
- Dec 09, 1997 V2.21 Corrected a minor bug in ReceiveStr. Detected by
- david@e.co.za (David Butler).
- Dec 10, 1997 V2.22 Corrected a minor bug in Send which now correctly
- returns the number of bytes sent. Detected by
- james.huggins@blockbuster.com
- Dec 16, 1997 V2.23 Corrected a bug which prevented the receiving of datagram
- from a UDP socket.
- Thank to Mark Melvin (melvin@misrg.ml.org) for pointing it.
- Dec 20, 1997 V2.24 Added the PeekData function as suggested by Matt Rose
- mcrose@avproinc.com
- Dec 26, 1997 V2.25 Added the Text property as suggested by Daniel P. Stasinski
- <dse@pacific.net>. Made GetXPort work even when listening as
- suggested by is81024@cis.nctu.edu.tw.
- Jan 10, 1998 V2.26 Check for null hostname in DNSLookup
- Added DnsResultList with all IP addresses returned form DNS
- Jan 13, 1998 V2.27 a Added MultiThreaaded property to tell the component that
- it is working in a thread and should take care of it (call
- internal ProcessMessages in place of Application.ProcessMessages,
- and do not use the WaitCtrl object).
- Jan 15, 1998 V2.28 WMAsyncSelect revisited to work properly with NT winsock 2.
- Feb 10, 1998 V2.29 Added an OnError event. If not assigned, then the component
- raise an exception when the error occurs.
- Feb 14, 1998 V2.30 Published Text property
- Feb 16, 1998 V2.31 Added virtual methods to trigger events
- Renamed all event handler variable to begin with FOn
- Feb 26, 1998 V2.32 Added procedure PutDataInSendBuffer and PutStringInSendBuffer
- Using PutDataInSendBuffer you can place data in the send buffer
- without actualy trying to send it. This allows to place several
- (probably small) data chunk before the component attempt to send
- it. This prevent small packet to be sent. You can call
- Send(nil, 0) to force the component to begin to send data.
- If the buffer was not empty, PutDataInSendBuffer will just queue
- data to the buffer. This data will be sent in sequence.
- Mar 02, 1998 V2.33 Changed the error check with WSAstartup as pointed out by
- Donald Strenczewilk (dstrenz@servtech.com)
- Mar 06, 1998 V2.34 Added a runtime property to change the buffer size.
- Mar 27, 1998 V2.35 Adapted for C++Builder 3
- Apr 08, 1998 V2.36 Made SetDefaultValue virtual
- Apr 13, 1998 V2.37 Reset FDnsLookupHandle to 0 after a failed call to
- WSACancelAsyncRequest
- Apr 22, 1998 V2.38 Published AllSent property to let outside know if our
- buffer has some data unsent.
- Apr 28, 1998 V2.39 Added LingerOnOff and LingerTimeout. Default values are
- wsLingerOn and timeout = 0 to behave by default as before.
- This value is setup just before Connect. Call SetLingerOption to
- set the linger option on the fly (the connection must be
- established to set the option). See winsock.closesocket on line
- help (winsock.hlp or win32.hlp) for a dsicussion of this option
- usage.
- May 06, 1998 V2.40 Added a workaround for Trumpet winsock inet_addr bug.
- Thanks to Andrej Cuckov <andrej@cuckov.com> for his code.
- May 18, 1998 V2.41 Jan Tomasek <xtomasej@feld.cvut.cz> found that Trumpet
- Winsock (Win 3.11) has some bugs and suggested a workaround in
- TryToSend procedure. This workaround makes TWSocket blocking in
- some cases. A new property enables the workaround. See code.
- Jun 01, 1998 V2.42 In finalization section, check for not assigned IPList.
- Jun 15, 1998 V2.43 Added code to finalization section to unload winsock if
- still loaded at that point (this happend if no socket where
- created but WinsockInfo called). Suggested by Daniel Fazekas
- <fdsoft@dns.gyor-ph.hu>
- Jun 27, 1998 V2.44 Added checks for valid arguments in SetPort, SetProto
- and SetAddr. Deferred address resolution until Connect or Listen.
- Jul 08, 1998 V2.45 Adadpted for Delphi 4
- Jul 20, 1998 V2.46 Added SetWindowLong(FWindowHandle, 0, 0) in the destructor
- and a check for TWSocket class in XSocketWindowProc.
- Added virtual method RealSend.
- Jul 23, 1998 V2.47 Added a TriggerSessionClosed from TryToSend in case of
- send error. This was called before, but with a nul error argument.
- Now it correctly gives the error number.
- Added a trashcan to receive data if no OnDataAvailable event
- handler is installed. Just receive the data and throw it away.
- Added reverse dns lookup asynchronous code (IP -> HostName).
- Thanks to Daniel Fazekas <fdsoft@dns.gyor-ph.hu> for his code.
- Jul 30, 1998 V2.48 Changed local variable "error" by FLastError in SocketError
- to make it available from the OnError handler. Thanks to
- dana@medical-info.com for finding this bug.
- In Abort procedure, deleted all buffered data because it was send
- the next time the socket is opened !
- Added CancelDnsLookup in Abort procedure.
- Aug 28, 1998 V2.49 Made InternalClose and ReceiveStr virtual
- Sep 01, 1998 V2.50 Ignore CancelDnsLookup exception during destroy
- Sep 29, 1998 V2.51 In InternalClose, protect AssignDefaultValue with
- try/except because SessionClosed event handler may have destroyed
- the component.
- Oct 11, 1998 V2.52 Changed Shutdown(2) to Shutdown(1) in Internal Close to
- prevent data lost on send. You may have to call Shutdown(2) in
- your own code before calling Close to have the same behaviour as
- before.
- Changed argument type for ASyncReceive and passed 0 from FD_CLOSE
- message handler.
- Oct 28, 1998 V2.53 Made WSocketLoadWinsock and WSocketUnloadWinsock public.
- Nov 11, 1998 V2.54 Added OnDisplay event for debugging purpose
- Nov 16, 1998 V2.55 Ignore WSANOTINITIALIZED error calling CloseSocket. This
- occurs when using TWSocket from a DLL and the finalization
- section is called before destroying TWSocket components (this is
- a program logic error).
- Made some properties and methods protected instead of private.
- Made some methods virtual.
- Added an Error argument to InternalClose.
- Added DoRecv virtual function.
- Added WSocketResolvePort
- Added WSocketResolveProto
- Deferred port and protocol resolution until really needed
- Transformed Listen to procedure (in case of failure Listen
- always calls SocketError which triggers an exception or the
- OnError event).
- Nov 22, 1998 V3.00 Skipped from V2.55 to V3.00. Socks support is major update!
- Added SOCKS5 (RFC-1928) support for TCP connection and
- simple usercode passwword authentication.
- Consider the socks code as beta !
- New properties: SocksServer, SocksPort, SocksUsercode,
- SocksPassword, FSocksAuthentication. New events: OnSocksError,
- OnSocksConnected, OnSocksAuthState.
- I used WinGate 2.1d to test my code. Unfortunately WinGate do
- not correctly handle user authentication, so the code here is
- just untested...
- Dec 05, 1998 V3.10 Removed ReadLine feature using TWait component.
- Added new TCustomLineWSocket and TCustomSyncWSocket.
- Those modifications implies that the ReadLine functionnality is
- slightly changed. Notably, the end of line marker is now
- configurable and remains in the received line unless a timeout
- occurs or the buffer is too small.
- Dec 10, 1998 V3.11 Added missing code to resolve port in the Listen method.
- Dec 12, 1998 V3.12 Added write method for LocalPort property. Thanks to
- Jan Tomasek <xtomasej@feld.cvut.cz> for his code.
- Added background exception handling.
- Fixed a bug in TCustomLineWSocket.TriggerDataAvailable which was
- not calling the inherited function when it actually should.
- Added a check on multithreaded in WaitForClose to call the
- correct ProcessMessages procedure.
- Added SOCKS4 support (only tcp connect is supported).
- Dec 28, 1998 V3.13 Changed WSocketResolveHost to check for invalid numeric
- IP addresses whitout trying to use them as hostnames.
- Dec 30, 1998 V3.14 Changed SetPort to SetRemotePort to solve the SetPort
- syndrome with BCB. Also chnaged GetPort to be consistant.
- Jan 12, 1999 V3.15 Introduced DoRecvFrom virtual function. This correct a bug
- introduced in V3.14 related to UDP and RecvFrom.
- Jan 23, 1999 V3.16 Changed FRcvdFlag computation in DoRecv and DoRecvFrom
- because it caused problems with HTTP component and large blocks.
- Removed modification by Jan Tomasek in TriggerDataAvailable
- Jan 30, 1999 V3.17 Added WSocketResolveIp function.
- Checked for tcp protocol before setting linger off in abort.
- Moved a lot of variables from private to protected sections.
- Removed check for Assigned(FOnDataSent) in WMASyncSelect.
- Feb 03, 1999 V3.18 Removed useless units in the uses clause.
- Feb 14, 1999 V4.00 Jump to next major version number because lots of
- fundamental changes have been done. See below.
-
- Use runtime dynamic link with winsock. All winsock functions
- used by TWSocket are linked at runtime instead of loadtime. This
- allows programs to run without winsock installed, provided program
- doesn't try to use TWSocket or winsock function without first
- checking for winsock installation.
- Removed WSocketLoadWinsock and all use to DllStarted because it
- is no longer necessary because winsock is automatically loaded
- and initialized with the first call to a winsock function.
-
- Added MessagePump to centralize call to the message pump.
- It is a virtual procedure so that you can override it to
- cutomize your message pump. Also changed slightly ProcessMessages
- to closely match what is done in the forms unit.
-
- Removed old stuff related to WaitCtrl (was already excluded from
- compilation using a conditional directive).
-
- Added NOFORMS conditional compilation to exclude the Forms unit
- from wsocket. This will reduce exe or dll size by 100 to 150KB.
- To use this feature, you have to add NOFORMS in your project
- options in the "defines" edit box in the "directory/conditional"
- tab. Then you must add a message pump to your application and
- call it from TWSocket.OnMessagePump event handler. TWSocket really
- need a message pump in order to receive messages from winsock.
- Depending on how your application is built, you can use either
- TWSocket.MessageLoop or TWSocket.ProcessMessages to quickly build
- a working message pump. Or you may build your own custom message
- pump taylored to your needs. Your message pump must set
- TWSocket.Terminated property to TRUE when your application
- terminates or you may experience long delays when closing your
- application.
- You may use NOFORMS setting even if you use the forms unit (GUI
- application). Simply call Application.ProcessMessages in the
- OnMessagePump event handler.
- OnMessagePump event is not visible in the object inspector. You
- must assign it at run-time before using the component and after
- having created it (in a GUI application you can do that in the
- FormCreate event, in a console application, you can do it right
- after TWSocket.Create call).
- Feb 17, 1999 V4.01 Added LineEcho and LineEdit features.
- Feb 27, 1999 V4.02 Added TCustomLineWSocket.GetRcvdCount to make RcvdCount
- property and ReceiveStr work in line mode.
- Mar 01, 1999 V4.03 Added conditional compile for BCB4. Thanks to James
- Legg <jlegg@iname.com>.
- Mar 14, 1999 V4.04 Corrected a bug: wsocket hangup when there was no
- OnDataAvailable handler and line mode was on.
- Apr 21, 1999 V4.05 Added H+ (long strings) and X+ (extended syntax)
- compilation options
- May 07, 1999 V4.06 Added WSAECONNABORTED to valid error codes in TryToSend.
- Jul 21, 1999 V4.07 Added GetPeerPort method, PeerPort and PeerAddr propertied
- as suggested by J. Punter <JPunter@login-bv.com>.
- Aug 20, 1999 V4.05 Changed conditional compilation so that default is same
- as latest compiler (currently Delphi 4, Bcb 4). Should be ok for
- Delphi 5.
- Added LocalAddr property as suggested by Rod Pickering
- <fuzzylogic123@yahoo.com>. LocalAddr default to '0.0.0.0' and is
- intended to be used by a client when connecting to a server, to
- select a local interface for multihomed computer. Note that to
- select an interface for a server, use Addr property before
- listening.
- LocalAddr has to be an IP address in dotted form. Valid values are
- '0.0.0.0' for any interface, '127.0.0.1' for localhost or any
- value returned by LocalIPList.
- Replaced loadtime import for ntohs and getpeername by runtime
- load.
- Revised check for dotted numeric IP address in WSocketResolveHost
- to allow correct handling of hostnames beginning by a digit.
- Added OnSendData event. Triggered each time data has been sent
- to winsock. Do not confuse with OnDataSent which is triggered
- when TWSocket internal buffer is emptyed. This event has been
- suggested by Paul Gertzen" <pgertzen@livetechnology.com> to
- easyly implement progress bar.
- Corrected WSocketGetHostByAddr to make it dynamically link to
- winsock.
- Sep 5, 1999 V4.09 Added CloseDelayed method.
- Make sure that TriggerSessionClosed is called from WMASyncSelect
- and InternalClose, even if there is no OnSessionClosed event
- handler assigned. This is required to make derived components
- work correctly.
- Created message WM_TRIGGER_EXCEPTION to help checking background
- exception handling (OnBgException event).
- Corrected bug for Delphi 1 and ReallocMem.
- Oct 02, 1999 V4.10 Added Release method.
- Oct 16, 1999 V4.11 Corrected a bug in TCustomLineWSocket.DoRecv: need to move
- data in front of buffer instead of changing buffer pointer which
- will crash the whole thing at free time.
- Oct 23, 1999 V4.12 Made WSocketIsDottedIP a public function
- Nov 12, 1999 V4.13 removed 3 calls to TriggerSocksAuthState because it was
- called twice. By A. Burlakov <alex@helexis.com>.
- Jan 24, 1999 V4.14 Call Receive instead of DoRecv from ReceiveStr to be sure
- to set LastError correctly. Thanks to Farkas Balazs
- <megasys@www.iridium.hu>
- Suppressed FDllName and used winsocket constant directly. I had
- troubles with some DLL code and string handling at program
- termination.
- Apr 09, 2000 V4.15 Added error number when resolving proto and port
- Apr 29, 2000 V4.16 Added WSocketForceLoadWinsock and
- WSocketCancelForceLoadWinsock. Thanks to Steve Williams.
- Created variable FSelectEvent to store current async event mask.
- Added ComponentOptions property with currently only one options
- wsoNoReceiveLoop which disable a receive loop in AsyncReceive.
- This loop breaking was suggested by Davie <smatters@smatters.com>
- to lower resource usage with really fast LAN and large transfers.
- By default, this option is disabled so there is no change needed
- in current code.
- May 20, 2000 V4.17 Made TSocket = u_int (same def as in winsock.pas)
- Moved bind after setting options.
- Thanks to Primoz Gabrijelcic <fab@siol.net>
- Jul 15, 2000 V4.18 Alon Gingold <gingold@hiker.org.il> changed
- TCustomSocksWSocket calls to inherited triggers of
- TriggerSessionConnected and TriggerDataAvailable.
- Now, it calls the trigger directly. This solves the problem
- of descendent classes with overridden triggers, not being
- called when a REAL connection was established, and when real
- data starts coming in. Special care MUST be taken in such
- overridden triggers to ONLY call the inherited trigger AND
- IMMEDIATELY EXIT when FSocksState <> socksData to avoid loopback
- Jul 22, 2000 V4.19 John Goodwin <john@jjgoodwin.com> found a failure in the
- logic for DnsLookup. He also implemented a workaround.
- See DnsLookup comments for explanation.
- Aug 09, 2000 V4.20 Alon Gingold <gingold2@mrm-multicat.com> found a bug in
- SOCKS4 implementation where a nul byte was incorrectly added
- (it should be added only with SOCKS4A version, not straith
- SOCKS4).
- Sep 17, 2000 V4.21 Eugene Mayevski <Mayevski@eldos.org> added TWndMethod for
- NOFORMS applications in other components.
- Oct 15, 2000 V4.22 Added method GetXAddr which returns local IP address to
- which a socket has been bound. There was already a GetXPort.
- Thanks to Wilfried Mestdagh <wilfried_sonal@compuserve.com>
- and Steve Williams <stevewilliams@kromestudios.com>.
- Nov 08, 2000 V4.23 Moved FSelectEvent from private to protected section.
- Nov 11, 2000 V4.24 Added LineLimit property and OnLineLimitExceeded event.
- When using line mode, line length is checked as each data block is
- comming. If the length is greater than the limit, then the event
- is triggered. You have the opportunity to close the socket or
- change the limit to a higher value. Thus you can prevent a hacker
- from locking your system by sending unlimited line which otherwise
- would eat up all system resources.
- Changed line handling variables to LongInt
- Checked all length involved in StrPCopy calls.
- Nov 26, 2000 V4.25 Do not trust GetRcvdCount. Always call Receive to check for
- incomming data (sometime NT4 will hang if we don't do that).
- Jan 24, 2001 V4.26 Blaine R Southam <bsoutham@iname.com> fixed out of bound
- error in TCustomLineWSocket.TriggerDataAvailable
- Feb 17, 2001 V4.27 Davie <smatters@smatters.com> fixed a bug causing byte lost
- when closing (related to wsoNoReceiveLoop option).
- May 04, 2001 V4.28 Fixed W2K bug (winsock message ordering)
- Jun 18, 2001 V4.29 Added AllocateHWnd and DeallocateHWnd from Forms unit to
- avoid warning from Delphi 6 in all other components.
- Jul 08, 2001 V4.30 Fixed small bug related to NOFOMRS and V4.29
- Jul 26, 2001 V4.31 Checked csDesigning in GetRcvdCount so that Delphi 6 does'nt
- crash when object inspector wants to display RcvdCount value.
- Added multicast capability and UDP ReuseAddr. Thanks to Mark
- G. Lewis <Lewis@erg.sri.com> for his code.
- Added TriggerSessionClosed to SocketError as suggested by Wilfried
- Mestdagh <wilfried_sonal@compuserve.com>
- Jul 28, 2001 V4.32 New option wsoTcpNoDelay implemented. Code by Arnaldo Braun
- <abraun@th.com.br>
- Jul 30, 2001 V4.33 Corrected at few glitches with Delphi 1
- Sep 08, 2001 V4.34 Added ThreadAttach and related functions
- Nov 27, 2001 V4.35 Added type definition for in_addr and Delphi 2 (Yes there are
- still some peoples who wants to use it. Don't ask me why !).
- Dec 02, 2001 V4.36 david.brock2@btinternet.com found a bug in SOCKS4 where
- error check incorrectly checked "FRcvBuf[1] = #$90" instead of
- "FRcvBuf[1] <> #90". He also found a bug when receiving domain name
- where length of name was incorrectly copyed to the buffer.
- Dec 23, 2001 V4.37 Removed bWrite, nMoreCnt, bMoreFlag and nMoreMax which where
- not more really used. Thanks to Al Kirk <akirk@pacific.net> for
- showing that.
- Feb 24, 2002 V4.38 Wilfried Mestdagh <wilfried@mestdagh.biz> added ThreadDetach
- and a property editor for LineEnd. XSocketDeallocateHWnd made a
- function.
- I created a new unit WSocketE.pas to put Wilfried's property
- editor so that it works correctly with Delphi 6.
- Apr 24, 2002 V4.39 Removed OnLineTooLong event which was not used anywhere.
- Use OnLineLimitExceeded event if you used this event.
- Thanks to Alex Kook <cookis@mail.ru> for finding this one.
- Apr 27, 2002 V4.40 Added procedure WSocketUnregisterClass to be able to
- unregister hidden window. This is necessary when TWSocket is
- used within a DLL which is unloaded and reloaded by applications,
- specially when running with Windows-XP. Thanks to Jean-Michel Aliu
- <jmaliu@jmasoftware.com> who provided a test case.
- Jun 02, 2002 V4.41 allow SOCK_RAW in Connect method for any protocol which is
- not TCP or UDP. Thanks to Holger Lembke <holger@hlembke.de>.
- Jun 04, 2002 V4.42 Do not call Listen for SOCK_RAW.
- Thanks to Holger Lembke <holger@hlembke.de>.
- Jun 08, 2002 V4.43 Add a dummy Register procedure for BCB1.
- Thanks to Marc-Alexander Prowe <listen@mohajer.de>.
- Jul 07, 2002 V4.44 Added code in Connect method to check if socket still opened
- after OnChangeState event. If not, trigger an error WSAINVAL.
- Sep 16, 2002 V4.45 Exposed RcvdPtr and RcvdCnt readonly properties.
- Sep 17, 2002 V4.46 Used InterlockedIncrement/InterlockedDecrement to Inc/Dec
- socket count safely when TWSocket is used within a thread. This
- was proposed by Matthew Meadows <matthew.meadows@inquisite.com>
- Sep 28, 2002 V4.47 Changed DnsLookup so that a hostname is checked for dotted
- IP addresse and resolve it numerically. Thanks to Bogdan Calin
- <soul4blade@yahoo.com> who found this bug. Alos loaded the result
- list with the address to be consistant with real lookup result.
- Nov 17, 2002 V4.48 Roland Klabunde <roland.klabunde@gmx.net> found a bug in
- multicast code: listening on a specific interface was ignored.
- He fixed Listen and Connect.
- Nov 27, 2002 V4.49 Added ListenBacklog property, default to 5.
- Dec 17, 2002 V4.50 Moved code to virtual function to permit SSL implementation.
- Jan 19, 2003 V5.00 First pre-release for ICS-SSL. New major version number
- V5.01 Gabi Slonto <buffne01@gmx.net> found a bug in DnsLookup
- when hostname was actulally a dotted IP address.
- Mar 18, 2003 V5.02 Fixed WSocketIsDottedIP: reordering of boolean expressions
- involaving a string. Thanks to Ian Baker <ibaker@codecutters.org>
- Apr 30, 2003 V5.03 Replaced all calls to setsockopt by calls to
- WSocket_setsockopt to avoid statically linked winsock DLL.
- Thanks to Piotr Dalek <enigmatical@interia.pl>.
- Also replaced inet_addr by WSocket_inet_addr.
- Aug 27, 2003 V5.04 Marco van de Voort <marcov@stack.nl> added FreePascal (FPC)
- conditional compilation. Please contact him for any FPC support
- question.
- Aug 28, 2003 V5.05 Fixed a multithreading issue related to windows class
- registration. Now using a critical section around the code.
- Thanks to Bogdan Ureche <bureche@omnivex.com> for his precious help.
- Aug 31, 2003 V5.06 Added warning about deprecated procedures Synchronize,
- WaitUntilReady and ReadLine. Do not use them in new applications.
- Sep 03, 2003 V5.07 Bogdan Ureche <bureche@omnivex.com> added a critical section
- to avoid problem when winsock.dll is unloaded by a thread while
- another thread is still using some TWSocket.
- Sep 15, 2003 V5.08 Fixed finalization section to no free critical section if
- a TWSocket is still existing. This happend for example when a
- TWSocket is on a form and Halt is called from FormCreate event.
- Changed SendStr argument to const.
- Nov 09, 2003 V5.09 Added manifest constants for Shutdown
- Added TCustomLineWSocket.SendLine method.
- Jan 16, 2004 V5.10 Added "const" in front of all method using strings.
- Jan 17, 2004 V5.11 Modified TriggerDataAvailable so that when in LineMode, we
- check if a line is still in the buffer of already received data.
- Also updated WMTriggerDataAvailable to avoid infinite loops.
- Introduced FLineFound to flag when a line has been found.
- See "OLD_20040117" to find this code.
- Jan 21, 2004 V5.12 Checked null string in PutStringInSendBuffer and null
- pointer in PutDataInSendBuffer.
- Jan 26, 2004 V5.13 Conditional compilation for BCB for constants for Shutdown.
- Reordered uses clause for FPC compatibility.
- Fixed TCustomLineWSocket.TriggerDataAvailable to deliver data
- already received while in line mode but after component user
- turned line mode off in the middle of the way. This could occur
- for example in a HTTP application where line mode is used to
- receive HTTP header line and turned off when last header line is
- found. At that point, if posted data (HTTP document) was completely
- in the same packet as the last header line, that data was not
- delivered until the next packet comes, which could never occur !
- Mar 20, 2004 V5.14 Added partial support for RAW socket.
- To use RAW sockets, set Proto to 'raw_ip', 'raw_icmp', ...
- Set Port to '0' or whatever value is useful for the protocol.
- When using IP protocol, you can add option wsoSIO_RCVALL so that
- your program receive ALL datagrams when you listen on a given
- interface (You can't use 0.0.0.0).
- Do not use Connect with RAW socket. Always use Listen and then
- use SendTo to send datagrams use the socket.
- Added ReqVerHigh and ReqVerLow properties to be able to select
- which winsock version you want to load. Default to 1.1 but need
- 2.2 for RAW sockets to be used.
- Mar 24, 2004 V5.15 Changed WSocket_Synchronized_ResolveProto to hard code
- protocol number for tcp, udp and raw.
- Apr 17, 2004 V6.00 New major release started. Move all platform and runtime
- dependencies to separate units. New base component for handling
- component with window handle.
- Jun 20, 2004 V 5.16 John Mulvey <john@mulvey.eurobell.co.uk> fixed error message
- in GetPeerAddr which incorrectly reported an error about
- GetPeerName.
- May 23, 2005 V5.17 PutDataInSendBuffer set bAllSent to false.
- Jun 03, 2005 V5.18 Added SocketSndBufSize property which gives the size of
- winsock internal send buffer. When using TCP, you must make sure
- you never use a BufSize equal or greater than this value or
- you'll experience bad performances. See description in MSDN
- http://support.microsoft.com/default.aspx?scid=kb;en-us;823764
- Default value for BufSize is 1460 and SocketSndBufSize is 8192 so
- there is no problem when not changing those values.
- Jun 18, 2005 V5.19 Made TCustomSocksWSocket.Connect accept 'tcp' as well as '6'
- for protocol. By Piotr "Hellrayzer" Dalek.
- Renamed event OnDisplay to OnDebugDisplay.
- Sept 4, 2005 V5.20 added BufferedByteCount property used to ensure winsock has sent
- data, currently used in TFtpCli to check a put has finished correctly
- Thanks to Tobias Giesen <tobias@tgtools.de> for the fix
- Dec 27, 2005 V6.00a Updated new release with change done in the old release.
- Dec 31, 2005 V6.00b added new debug and logging event and log levels, replacing
- conditional debug code with optional code to avoid rebuilding apps.
- Works in combination with new component TIcsLogger.
- This is controlled by the new LogOptions property:
- loDestEvent - write to OnIcsLogEvent (called from higher level protocols)
- loDestFile - write to file debug_out.myprog.txt
- loDestOutDebug - write to OutputDebugString (shown in Debugger Event Log window)
- loAddStamp - time stamp each log line (accurate only to about 18ms)
- loWsockErr - log wsocket errors
- loWsockInfo - log wsocket general information
- loWsockDump - log wsocket data (not implemented yet)
- loSslErr - log SSL errors
- loSslInfo - log SSL general information
- loSslDump - log SSL packets and data
- loProtSpecErr - log protocol specific error
- loProtSpecInfo - log protocol specific general information
- loProtSpecDump - log protocol specific data and packets
- Jan 22, 2006 V6.00c Added some KeepAlive stuff (seems winsock is bugged and
- doesn't care any setting done !).
- Jan 28, 2006 V6.00d Gerhard Rattinger fixed SetKeepAliveOption for Delphi 3
- Mar 09, 2006 V6.00e Arno made properties to select keepalive parameters.
- He also fixed ReverseDnsLookup to return a list of
- host names (aliases) instead of just the first entry. Added func.
- ReverseDnsLookupSync.
- Apr 27, 2006 V6.00f Roger Tinembart <tinembart@brain.ch> added a critical section
- around the list of sendbuffers (FBufHandler) to avoid problems when
- the data is placed in the sendbuffer (for example with SendStr)
- by a different thread than the one that is effectively sending the
- data with TryToSend
- June 11, 2006 V6.01 Use new TIcsBufferHandler.
- Aug 06, 2006 V6.02 Angus added GetWinsockErr to give alpha and numeric winsock
- errors and improved many other error messages,
- and fixed FReadCount for 64-bit downloads
- added some EXTERNALSYM for BCB compatiblity
- Aug 18, 2006 V6.03 Fixed a bug in ASyncReceive(). This bug caused data loss.
- Oct 28, 2006 V6.04 Added setter for SocketSndBufSize and SocketRcvBufSize
- Dec 22, 2006 V6.05 Oliver Grahl fixed SendLine to properly count LineEnd characters.
- Jan 18, 2007 V6.06 Fixed constructor and DeleteBufferedData to behave correctly
- when an exception occur in AllocateSocketHWnd.
- Mar 23, 2007 V6.07 Removed FD_CONNECT from dup().
- Apr 04, 2007 V6.08 Arno Garrels updated SetKeepAliveOption
- Mar 10, 2008 V6.09 Francois Piette & Arno Garrels made some changes to
- prepare code for Unicode
- WSocket_gethostname conversion from String to AnsiString
- WSocketGetProc and WSocket2GetProc use AnsiString
- GetAliasList simplified and use AnsiString
- Apr 25, 2008 V6.10 A. Garrels, added some getters/setters to store and use some
- string-property-values as AnsiString internally.
- This reduced number of string casts with potential data loss to 17.
- These ansi-values are used to call winsock API that doesn't provide
- W functions. Modified depending code including some type changes
- from PChar to PAnsiChar. Made some casts Unicode => Ansi with
- potential data loss *explicit* casts (conditionally compiled) some
- unicode strings with only 7 bit ASCII characters are casted using
- new function UnicodeToAscii() in new unit OverbyteIcsUtils which
- should be fast and reliable and doesn't produce compiler warnings.
- Added new warning symbols.
- Apr 30, 2008 V6.11 A. Garrels - Function names adjusted according to changes in
- OverbyteIcsLibrary.pas.
- May 11, 2008 V6.12 USchuster removed local atoi implementation (atoi is now in
- OverbyteIcsUtils.pas)
- May 15, 2008 V6.13 AGarrels type change of some published String properties
- to AnsiString, this is an attempt to avoid too many implicit
- string casts, only a few higher level components have been adjusted
- accordingly so far.
- Jun 30, 2008 A.Garrels made some changes to prepare SSL code for Unicode.
- Jul 04, 2008 V6.11 Rev.58 SSL - Still lacked a few changes I made last year.
- Jul 13, 2008 V6.12 Added SafeWSocketGCount
- Aug 03, 2008 V6.16 A. Garrels removed packed from record TExtension.
- Jul 07, 2008 V6.17 Still a small fix from December 2007 missing in SSL code.
- Aug 11, 2008 V6.18 A. Garrels - Type AnsiString rolled back to String.
- Two bugs fixed in SSL code introduced with Unicode change.
- Socks was not fully prepared for Unicode.
- Sep 19, 2008 V6.19 A. Garrels changed some AnsiString types to RawByteString.
- Sep 21, 2008 V6.20 A. Garrels removed BoolToStr(), available since D7
- Oct 22, 2008 V7.21 A. Garrels removed the const modifier from parameter Data
- in function SendTo to fix a bug in C++ Builder.
- Nov 03, 2008 V7.22 Added property Counter, a class reference to TWSocketCounter
- which provides some useful automatic counters. By default property
- Counter is unassigned and has to be enabled by a call to
- CreateCounter.
- Apr 24, 2009 V7.23 A. Garrels added *experimental* OpenSSL engine support which
- is not compiled in by default. You have to uncomment conditional
- define OPENSSL_NO_ENGINE in OverbyteIcsSslDefs.inc and rebuild your
- packages to get it included. With engine support included a new
- published property AutoEnableBuiltinEngines of TSslContext has to
- be set to TRUE in order to enable OpenSSL's built-in hardware
- accelerators support, that's all.
-
- ******************************************************************
- * Due to the lack of hardware this feature is completely untested*
- ******************************************************************
-
- Any feedback and fixes are welcome, please contact the ICS mailing
- list. The OpenSSL engine documentation can be found here:
- http://openssl.org/docs/crypto/engine.html
-
- Additionally a new component TSslEngine is installed on the palette.
- Its purpose is to control (dynamic) engines.
-
- Typically control commands of an OpenSC dynamic pkcs11 engine
- (SmartCard) are :
-
- Cmds.Add('SO_PATH=d:\opensc\bin\engine_pkcs11.dll');
- Cmds.Add('ID=pkcs11');
- Cmds.Add('LIST_ADD=1');
- Cmds.Add('LOAD=');
- Cmds.Add('MODULE_PATH=d:\opensc\bin\opensc-pkcs11.dll');
- Cmds.Add('INIT='); <= Special ICS-control command to initialize the engine
-
- Sample test code (Dod couldn't get it working :(
-
- It assumes that the X509 certificate has been exported from
- the SmartCard to PEM file that is available in property
- SslCertFile. It's also assumed that SslEngine1 is created
- dynamically at run-time in this sample.
- We are in new event TSslContext.OnBeforeInit:
-
- if not Assigned(SslEngine1) then
- begin
- SslEngine1 := TSslEngine.Create(Self);
- try
- SslEngine1.NameID := 'dynamic';
-
- // The SmartCard holds the private key.
- // Next two lines advise SslContext to load the key
- // from the engine instead from PEM file.
- TSslContext(Sender).CtxEngine := SslEngine1;
- SslEngine1.CtxCapabilities := [eccLoadPrivKey];
-
- // The PIN code is expected in property SslPassPhrase
- TSslContext(Sender).SslPassPhrase := 'ics';
-
- // Tell the engine which key to use.
- SslEngine1.KeyID := KeyIdEdit.Text;
-
- // At first open the engine
- if not SslEngine1.Open then
- raise Exception.Create(FEngine.LastErrorMsg);
-
- // Now send our vendor specific control commands
- for I := 0 to Cmds.Count -1 do
- begin
- if not SslEngine1.Control(Cmds.Names[I],
- Cmds.ValueFromIndex[I]) then
- raise Exception.Create(SslEngine1.LastErrorMsg);
- end;
-
- Display('Engine set up and loaded successfully');
- except
- FreeAndNil(SslEngine1);
- raise;
- end;
- end;
-
- Jun 12, 2009 V7.24 Angus added WriteCount property, how many bytes sent since
- connection opened
- Only reset ReadCount when connection opened, not closed
- Jul 16, 2009 V7.25 Arno fixed and changed SetCounterClass()
- Jul 19, 2009 V7.26 Arno - SSL code ignored FPaused flag, the change is in
- TCustomSslWSocket.TriggerEvent.
- Sep 04, 2009 V7.27 Set option TCP_NODELAY in Dup as well as provide a public
- method to set this option, similar as suggested by
- Samuel Soldat.
- Sep 08, 2009 V7.28 Arno - Minor Unicode bugfix in TX509Base.GetExtension().
- Sep 09, 2009 V7.29 Arno - Added new public methods TX509Base.WriteToBio() and
- TX509Base.ReadFromBio(). Method SafeToPemFile got an arg.
- that adds human readable certificate text to the output.
- InitializeSsl inlined. Removed a Delphi 1 conditional.
- Sep 17, 2009 V7.30 Anton Sviridov optimized setting of SSL options.
- Sep 17, 2009 V7.31 Arno fixed a Unicode bug in TX509Base.GetExtension and
- a general bug in TX509Base.GetSha1Hash (AnsiString as
- digest buffer should really be avoided)
- Sep 18, 2009 V7.32 Arno changed visibility of TX509Base.WriteToBio() and
- TX509Base.ReadFromBio() to protected.
- Nov 01, 2009 V7.33 Arno fixed a memory overwrite bug in
- TCustomSocksWSocket.DoRecv().
- Nov 07, 2009 V7.34 OpenSSL V0.9.8L disables session renegotiation due to
- TLS renegotiation vulnerability.
- Dec 20, 2009 V7.35 Arno added support for SSL Server Name Indication (SNI).
- SNI has to be turned on in OverbyteIcsSslDefs.inc, see define
- "OPENSSL_NO_TLSEXT". Exchanged symbol "NO_ADV_MT" in the
- SSL source by "NO_SSL_MT" (This and SNI was sponsored by
- Fastream Technologies).
- SNI Howto: In SSL server mode assign event OnSslServerName,
- it triggers whenever a client sent a server name in the TLS
- client helo. From the event handler read public property
- SslServerName, lookup and pass a matching, valid and
- initialized SslContext instance associated with the server name.
- In SSL client mode, if property SslServerName was not empty
- this server name is sent to the server in the TLS client helo.
- Currently IE 7 and FireFox >= V2 support SNI, note that both
- browers don't send both "localhost" and IP addresses as
- server names, this is specified in RFC.
- Dec 24, 2009 V7.36 SSL SNI - Do not switch context if not initialized.
- Dec 26, 2009 V7.37 Arno fixed TCustomSyncWSocket.ReadLine for Unicode. It
- now takes an AnsiString buffer. Since this method is highly
- deprecated it's also marked as "deprecated". Do not use it
- in new applications.
- May 08, 2010 V7.38 Arno Garrels added support for OpenSSL 0.9.8n. Read comments
- in OverbyteIcsLIBEAY.pas for details.
- May 16, 2010 V7.39 Arno Garrels reenabled check for nil in WMAsyncGetHostByName.
- Jun 10, 2010 V7.40 Arno Garrels added experimental timeout and throttle feature
- to TWSocket. Currently both features have to be enabled
- explicitly with conditional defines BUILTIN_TIMEOUT
- and/or BUILTIN_THROTTLE (see OverbyteIcsDefs.inc )
- Aug 02, 2010 V7.41 Arno removed an option to send plain UTF-16 strings with
- SendStr() and SendLine() by passing 1200 (CP_UTF16) in the
- codepage parameter. Changed SendLine() to return correct
- number of bytes written.
- Aug 08, 2010 V7.42 FPiette prevented socket close in TCustomWSocket.Destroy when
- socket state is wsInvalidState (this happend when an
- exception is raise early in the constructor).
- Sep 05, 2010 V7.43 Arno fixed a bug in the experimental throttle and timeout
- source which made it impossible to use both features at the
- same time. Renamed conditionals EXPERIMENTAL_THROTTLE and
- EXPERIMENTAL_TIMEOUT to BUILTIN_THROTTLE and BUILTIN_TIMEOUT.
- It's now possible to either enable them in OverbyteIcsDefs.inc
- or define them in project options.
- Sep 08, 2010 V7.44 Arno reworked the experimental timeout and throttle code.
- …
Large files files are truncated, but you can click here to view the full file