1
{==============================================================================|
2
| Project : Ararat Synapse | 001.001.001 |
3
|==============================================================================|
4
| Content: Socket debug tools |
5
|==============================================================================|
6
| Copyright (c)2008-2010, Lukas Gebauer |
7
| All rights reserved. |
9
| Redistribution and use in source and binary forms, with or without |
10
| modification, are permitted provided that the following conditions are met: |
12
| Redistributions of source code must retain the above copyright notice, this |
13
| list of conditions and the following disclaimer. |
15
| Redistributions in binary form must reproduce the above copyright notice, |
16
| this list of conditions and the following disclaimer in the documentation |
17
| and/or other materials provided with the distribution. |
19
| Neither the name of Lukas Gebauer nor the names of its contributors may |
20
| be used to endorse or promote products derived from this software without |
21
| specific prior written permission. |
23
| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
24
| AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
25
| IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
26
| ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR |
27
| ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
28
| DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
29
| SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
30
| CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
31
| LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
32
| OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH |
34
|==============================================================================|
35
| The Initial Developer of the Original Code is Lukas Gebauer (Czech Republic).|
36
| Portions created by Lukas Gebauer are Copyright (c)2008-2010. |
37
| All Rights Reserved. |
38
|==============================================================================|
40
|==============================================================================|
41
| History: see HISTORY.HTM from distribution package |
42
| (Found at URL: http://www.ararat.cz/synapse/) |
43
|==============================================================================}
45
{:@abstract(Socket debug tools)
47
Routines for help with debugging of events on the Sockets.
51
{$WARN IMPLICIT_STRING_CAST OFF}
52
{$WARN IMPLICIT_STRING_CAST_LOSS OFF}
60
blcksock, synsock, synautil, classes, sysutils;
63
TSynaDebug = class(TObject)
64
class procedure HookStatus(Sender: TObject; Reason: THookSocketReason; const Value: string);
65
class procedure HookMonitor(Sender: TObject; Writing: Boolean; const Buffer: TMemory; Len: Integer);
68
procedure AppendToLog(const value: Ansistring);
75
procedure AppendToLog(const value: Ansistring);
82
if fileexists(LogFile) then
83
st := TFileStream.Create(LogFile, fmOpenReadWrite or fmShareDenyWrite)
85
st := TFileStream.Create(LogFile, fmCreate or fmShareDenyWrite);
87
st.Position := st.Size;
89
decodetime(dt, h, m, ss, ms);
90
s := formatdatetime('yyyymmdd-hhnnss', dt) + format('.%.3d', [ms]) + ' ' + value;
91
WriteStrToStream(st, s);
97
class procedure TSynaDebug.HookStatus(Sender: TObject; Reason: THookSocketReason; const Value: string);
103
s := 'HR_ResolvingBegin';
105
s := 'HR_ResolvingEnd';
107
s := 'HR_SocketCreate';
109
s := 'HR_SocketClose';
125
s := 'HR_WriteCount';
133
s := inttohex(integer(Sender), 8) + s + ': ' + value + CRLF;
137
class procedure TSynaDebug.HookMonitor(Sender: TObject; Writing: Boolean; const Buffer: TMemory; Len: Integer);
142
move(Buffer^, pointer(s)^, len);
147
s :=inttohex(integer(Sender), 8) + d + s + CRLF;
153
Logfile := changefileext(paramstr(0), '.slog');
1
{==============================================================================|
2
| Project : Ararat Synapse | 001.001.001 |
3
|==============================================================================|
4
| Content: Socket debug tools |
5
|==============================================================================|
6
| Copyright (c)2008-2010, Lukas Gebauer |
7
| All rights reserved. |
9
| Redistribution and use in source and binary forms, with or without |
10
| modification, are permitted provided that the following conditions are met: |
12
| Redistributions of source code must retain the above copyright notice, this |
13
| list of conditions and the following disclaimer. |
15
| Redistributions in binary form must reproduce the above copyright notice, |
16
| this list of conditions and the following disclaimer in the documentation |
17
| and/or other materials provided with the distribution. |
19
| Neither the name of Lukas Gebauer nor the names of its contributors may |
20
| be used to endorse or promote products derived from this software without |
21
| specific prior written permission. |
23
| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
24
| AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
25
| IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
26
| ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR |
27
| ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
28
| DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
29
| SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
30
| CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
31
| LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
32
| OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH |
34
|==============================================================================|
35
| The Initial Developer of the Original Code is Lukas Gebauer (Czech Republic).|
36
| Portions created by Lukas Gebauer are Copyright (c)2008-2010. |
37
| All Rights Reserved. |
38
|==============================================================================|
40
|==============================================================================|
41
| History: see HISTORY.HTM from distribution package |
42
| (Found at URL: http://www.ararat.cz/synapse/) |
43
|==============================================================================}
45
{:@abstract(Socket debug tools)
47
Routines for help with debugging of events on the Sockets.
51
{$WARN IMPLICIT_STRING_CAST OFF}
52
{$WARN IMPLICIT_STRING_CAST_LOSS OFF}
60
blcksock, synsock, synautil, classes, sysutils;
63
TSynaDebug = class(TObject)
64
class procedure HookStatus(Sender: TObject; Reason: THookSocketReason; const Value: string);
65
class procedure HookMonitor(Sender: TObject; Writing: Boolean; const Buffer: TMemory; Len: Integer);
68
procedure AppendToLog(const value: Ansistring);
75
procedure AppendToLog(const value: Ansistring);
82
if fileexists(LogFile) then
83
st := TFileStream.Create(LogFile, fmOpenReadWrite or fmShareDenyWrite)
85
st := TFileStream.Create(LogFile, fmCreate or fmShareDenyWrite);
87
st.Position := st.Size;
89
decodetime(dt, h, m, ss, ms);
90
s := formatdatetime('yyyymmdd-hhnnss', dt) + format('.%.3d', [ms]) + ' ' + value;
91
WriteStrToStream(st, s);
97
class procedure TSynaDebug.HookStatus(Sender: TObject; Reason: THookSocketReason; const Value: string);
103
s := 'HR_ResolvingBegin';
105
s := 'HR_ResolvingEnd';
107
s := 'HR_SocketCreate';
109
s := 'HR_SocketClose';
125
s := 'HR_WriteCount';
133
s := inttohex(integer(Sender), 8) + s + ': ' + value + CRLF;
137
class procedure TSynaDebug.HookMonitor(Sender: TObject; Writing: Boolean; const Buffer: TMemory; Len: Integer);
142
move(Buffer^, pointer(s)^, len);
147
s :=inttohex(integer(Sender), 8) + d + s + CRLF;
153
Logfile := changefileext(paramstr(0), '.slog');