http://wiki.overbyte.eu/wiki/api.php?action=feedcontributions&user=Wilfried&feedformat=atomOverbyte - User contributions [en]2024-03-28T17:32:24ZUser contributionsMediaWiki 1.34.0http://wiki.overbyte.eu/wiki/index.php?title=TWSocket.Addr&diff=2111TWSocket.Addr2006-10-01T13:17:48Z<p>Wilfried: /* Special IP addresses */</p>
<hr />
<div>[[Main_Page | Main page]] -> [[ICS_Components_Reference | ICS component reference]] -> [[TWSocket]] -> [[TWSocket.Addr | Addr]]<br />
<br />
== Definition ==<br />
<br />
'''property''' Addr: '''string''';<br />
<br />
== Description ==<br />
<br />
=== Client ===<br />
<br />
The host to connect to. It can be a dotted IP address or a hostname. If it is a dotted IP address then [[TWSocket.Connect | Connect]] will return immediatly, if it is a hostname it will block until the hostname is resolved, so [[TWSocket.DNSLookup | DNSLookup]] is perferable.<br />
<br />
=== Server ===<br />
<br />
The interface to listen on. ''0.0.0.0'' means all interfaces. Note that for a TCP server the use of [[TWSocketServer]] is preferable.<br />
<br />
=== Special IP addresses ===<br />
* 0.0.0.0 means all interfaces (server only)<br />
* 127.0.0.1 is the localhost, usefull for testing purposes since the packets don't leave the own PC or if you don't know the IP of the local PC.<br />
<br />
== Example ==<br />
<br />
== Best practices ==<br />
<br />
== How to ==<br />
<br />
* Listen on multiple interfaces<br />
<br />
:You may listen on one interface (giving his IP address) or all interfaces (giving 0.0.0.0 as IP address). To listen to several IP addresses but not all, you have to use a TWSocket for each interface you want to listen to. Just use the same event handler for all your TWSocket components and of course always use sender argument in all those event handlers.<br />
<br />
:Note that this counts for a UDP listener and that for a TCP server the use of [[TWSocketServer]] is preferable.</div>Wilfriedhttp://wiki.overbyte.eu/wiki/index.php?title=User:Wilfried&diff=2110User:Wilfried2006-10-01T13:13:43Z<p>Wilfried: /* Drafts */</p>
<hr />
<div>== Drafts ==<br />
<br />
[http://www.overbyte.be/frame_index.html?redirTo=/support/tcpudp_primer.html TCP / UDP Primer]</div>Wilfriedhttp://wiki.overbyte.eu/wiki/index.php?title=User:Wilfried&diff=2109User:Wilfried2006-10-01T13:13:30Z<p>Wilfried: /* Drafts */</p>
<hr />
<div>== Drafts ==<br />
<br />
[http://www.overbyte.be/frame_index.html?redirTo=/support/tcpudp_primer.html TCP / UDP Primer]<br />
<br />
test</div>Wilfriedhttp://wiki.overbyte.eu/wiki/index.php?title=FAQ&diff=2019FAQ2006-05-06T06:59:14Z<p>Wilfried: /* FAQ */</p>
<hr />
<div>[[Main_Page | Main page]] -> [[FAQ]]<br />
<br />
<!--<br />
Here, you'll find the most Frequently Asked Questions about the components. Some links refer to articles and others on "How-to-do-things"<br />
--><br />
<br />
Here, you'll find the most frequently asked questions which cover a range of components or all. You will find questions specific to one component in the '''How to''' section of each component.<br />
<br />
== How ICS works ==<br />
{|<br />
| width="170" | [[Asynchronous_Paradigm | Asynchronous paradigm]] |||| The non-blocking nature of ICS.<br />
|-<br />
| [[Sending and receiving data]] |||| Draft discussing possible formats of data transfer.<br />
|}<br />
<br />
== FAQ ==<br />
{|<br />
| width="170" valign="top" | [[FAQ.Concatenating data | Concatenating data]] |||| A example on how to concatenate chuncks of data in a CPU / Memory friendly way.<br />
|-<br />
| valign="top" | [[FAQ.General | General]] |||| General questions not belong to other section<br />
|-<br />
| valign="top" | [[FAQ.Internet | Internet]] |||| Specific for internet<br />
|-<br />
| valign="top" | [[FAQ.MultiThreading | Multi-Threading]] |||| Using ICS components and threads<br />
|-<br />
| valign="top" | [[FAQ.ProgressBar | Progress bar]] |||| Implementing a progress bar<br />
|-<br />
| valign="top" | [[FAQ.Timeout | Timeouts]] |||| Implementing timeouts on connections or protocols<br />
|}<br />
<br />
<!--<br />
* [[THttpCli.FAQ.Timeout | How to implement a timeout for THttpCli in my application?]]<br />
* [[THttpCli.FAQ.Progress | How to implement a progress for THttpCli in my application?]]<br />
* [[THttpCli.FAQ.SizeLimit | How to implement a download size limitation for THttpCli in my application?]]<br />
--></div>Wilfriedhttp://wiki.overbyte.eu/wiki/index.php?title=User:Wilfried&diff=2018User:Wilfried2006-05-01T13:28:41Z<p>Wilfried: </p>
<hr />
<div>== Drafts ==<br />
<br />
[http://www.overbyte.be/frame_index.html?redirTo=/support/tcpudp_primer.html TCP / UDP Primer]</div>Wilfriedhttp://wiki.overbyte.eu/wiki/index.php?title=User:Wilfried&diff=2017User:Wilfried2006-05-01T13:25:48Z<p>Wilfried: </p>
<hr />
<div>== Drafts ==<br />
<br />
[http://www.overbyte.be/frame_index.html?redirTo=/support/tcpudp_primer.html TCP / UDP Primer]<br />
<br />
[[Delimited data]]</div>Wilfriedhttp://wiki.overbyte.eu/wiki/index.php?title=User:Wilfried&diff=2016User:Wilfried2006-05-01T13:22:07Z<p>Wilfried: </p>
<hr />
<div>== Drafts ==<br />
<br />
[http://www.overbyte.be/frame_index.html?redirTo=/support/tcpudp_primer.html TCP / UDP Primer]<br />
<br />
[[Delimited data]]<br />
<br />
== Tests ==<br />
<br />
[[:Category:Cat | Cat]]</div>Wilfriedhttp://wiki.overbyte.eu/wiki/index.php?title=User:Wilfried&diff=2015User:Wilfried2006-05-01T13:18:03Z<p>Wilfried: </p>
<hr />
<div>== Drafts ==<br />
<br />
[[Thread article ideas]]<br />
<br />
[http://www.overbyte.be/frame_index.html?redirTo=/support/tcpudp_primer.html TCP / UDP Primer]<br />
<br />
[[Delimited data]]<br />
<br />
== Tests ==<br />
<br />
[[:Category:Cat | Cat]]</div>Wilfriedhttp://wiki.overbyte.eu/wiki/index.php?title=FAQ.Concatenating_data&diff=2014FAQ.Concatenating data2006-05-01T13:17:24Z<p>Wilfried: </p>
<hr />
<div>[[Main_Page | Main page]] -> [[FAQ]] -> [[FAQ.Concatenating data | Concatenating data]]<br />
<br />
=== Why ===<br />
<br />
Many times it is necessary to concatenate data. For example when receiving data chuncks with [[TWSocket]], or to make a virtual HTML page with [[THttpServer]].<br />
<br />
One single advice is to not use strings in the form of:<br />
<br />
Rcvd := Rcvd + Buffer;<br />
<br />
Why not? Because every time you do that technically the following happens:<br />
<br />
* Rcvd is reallocated memory. Not a big deal if there happens to be enough room right at the end of the block, but chance is low. So there is a new block allocated.<br />
* The data in Rcvd is copied in the new block<br />
* The buffer is appended to the data in the new block<br />
* The original location memory is made free<br />
<br />
You can imagine that your memory does get fragmented if that happens a lot, because other parts in your program also need to allocate / free memory.<br />
<br />
=== Solution ===<br />
<br />
The solution is to make a buffer for the data. The buffer has to allocate enough memory for the whole data, and if there is not enough it should reallocate in a cpu / memory friendly way.<br />
<br />
Also the space has to be reused so that the allocation only happens one or a few time.<br />
<br />
=== Code explanation ===<br />
<br />
==== Creation ====<br />
<br />
We need to create the class with an expected maximum Size. We also tell the class how to increment if size should getting too small. Both of the arguments are depending on the expecting data of course.<br />
<br />
We allocate 1 byte more as we like to terminate the data with a NULL.<br />
<br />
'''constructor''' TMemBuilder.Create(Size, Increment: integer);<br />
'''begin'''<br />
FSize := Size + 1;<br />
GetMem(FData, FSize);<br />
FIncrement := Increment;<br />
'''end''';<br />
<br />
==== Adding data ====<br />
<br />
First we check if there is enough room. If not then we reallocate memory. Then we add the data to our buffer. We need in practice a few overloaded methods here, see therefore the complete code example.<br />
<br />
'''procedure''' TMemBuilder.Add(P: PChar; Len: integer);<br />
'''begin'''<br />
'''if''' FLen + Len >= FSize '''then begin'''<br />
FSize := FSize + Max(Len, FIncrement) + 1;<br />
ReAllocMem(FData, FSize);<br />
'''end''';<br />
Move(P^, FData[FLen], Len);<br />
Inc(FLen, Len);<br />
FData[FLen] := #0;<br />
'''end''';<br />
<br />
==== Reading data ====<br />
<br />
Nothing can be more simple. We just have to public a property that point to the beginning of our data. In case it is binary data we need also a length property. If you want the data to be a string then you can do a typecast but think twice as this make an extra copy.<br />
<br />
'''property''' Data: PChar '''read''' FData;<br />
'''property''' Len: integer '''read''' FLen;<br />
<br />
==== Clearing the buffer ====<br />
<br />
We keep our memory for reuse, so all we need to do is reset the length.<br />
<br />
'''procedure''' TMemBuilder.Clear;<br />
'''begin'''<br />
FLen := 0;<br />
FData[0] := 0;<br />
'''end''';<br />
<br />
=== Complete class ===<br />
<br />
This is the complete class. You can copy / paste it to use it.<br />
<br />
'''unit''' uMemBuilder;<br />
<br />
'''interface'''<br />
<br />
'''type'''<br />
TMemBuilder = '''class'''<br />
'''private'''<br />
FSize: integer;<br />
FLen: integer;<br />
FIncrement: integer;<br />
FData: PChar;<br />
'''function''' Max(a, b: integer): integer;<br />
'''public'''<br />
'''constructor''' Create(Size, Increment: integer);<br />
'''destructor''' Destroy; '''override''';<br />
'''procedure''' Clear;<br />
'''procedure''' Add(S: '''string'''); '''overload''';<br />
'''procedure''' Add(P: PChar); '''overload''';<br />
'''procedure''' Add(P: PChar; Len: integer); '''overload''';<br />
'''property''' Data: PChar '''read''' FData;<br />
'''property''' Len: integer '''read''' FLen;<br />
end;<br />
<br />
'''implementation'''<br />
<br />
<font color="green"><i>{ TMemBuilder }</i></font><br />
<br />
'''procedure''' TMemBuilder.Add(S: '''string''');<br />
'''var'''<br />
Len: integer;<br />
'''begin'''<br />
Len := Length(S);<br />
Add(PChar(S), Len);<br />
'''end''';<br />
<br />
'''procedure''' TMemBuilder.Add(P: PChar);<br />
'''var'''<br />
Len: integer;<br />
'''begin'''<br />
Len := Length(P);<br />
Add(P, Len);<br />
'''end''';<br />
<br />
'''procedure''' TMemBuilder.Add(P: PChar; Len: integer);<br />
'''begin'''<br />
'''if''' FLen + Len >= FSize '''then''' '''begin'''<br />
FSize := FSize + Max(Len, FIncrement) + 1;<br />
ReAllocMem(FData, FSize);<br />
'''end''';<br />
Move(P^, FData[FLen], Len);<br />
Inc(FLen, Len);<br />
FData[FLen] := #0;<br />
'''end''';<br />
<br />
'''procedure''' TMemBuilder.Clear;<br />
'''begin'''<br />
FLen := 0;<br />
FData[FLen] := #0;<br />
'''end''';<br />
<br />
'''constructor''' TMemBuilder.Create(Size, Increment: integer);<br />
'''begin'''<br />
FSize := Size + 1;<br />
GetMem(FData, FSize);<br />
FIncrement := Increment;<br />
'''end''';<br />
<br />
'''destructor''' TMemBuilder.Destroy;<br />
'''begin'''<br />
FreeMem(FData);<br />
inherited;<br />
'''end''';<br />
<br />
'''function''' TMemBuilder.Max(a, b: integer): integer;<br />
'''begin'''<br />
'''if''' a >= b '''then'''<br />
Result := a<br />
'''else'''<br />
Result := b;<br />
'''end''';<br />
<br />
'''end'''.<br />
<br />
rgds, Wilfried<br />
http://www.mestdagh.biz</div>Wilfriedhttp://wiki.overbyte.eu/wiki/index.php?title=FAQ.Concatenating_data&diff=2013FAQ.Concatenating data2006-05-01T13:16:06Z<p>Wilfried: </p>
<hr />
<div>=== Why ===<br />
<br />
Many times it is necessary to concatenate data. For example when receiving data chuncks with [[TWSocket]], or to make a virtual HTML page with [[THttpServer]].<br />
<br />
One single advice is to not use strings in the form of:<br />
<br />
Rcvd := Rcvd + Buffer;<br />
<br />
Why not? Because every time you do that technically the following happens:<br />
<br />
* Rcvd is reallocated memory. Not a big deal if there happens to be enough room right at the end of the block, but chance is low. So there is a new block allocated.<br />
* The data in Rcvd is copied in the new block<br />
* The buffer is appended to the data in the new block<br />
* The original location memory is made free<br />
<br />
You can imagine that your memory does get fragmented if that happens a lot, because other parts in your program also need to allocate / free memory.<br />
<br />
=== Solution ===<br />
<br />
The solution is to make a buffer for the data. The buffer has to allocate enough memory for the whole data, and if there is not enough it should reallocate in a cpu / memory friendly way.<br />
<br />
Also the space has to be reused so that the allocation only happens one or a few time.<br />
<br />
=== Code explanation ===<br />
<br />
==== Creation ====<br />
<br />
We need to create the class with an expected maximum Size. We also tell the class how to increment if size should getting too small. Both of the arguments are depending on the expecting data of course.<br />
<br />
We allocate 1 byte more as we like to terminate the data with a NULL.<br />
<br />
'''constructor''' TMemBuilder.Create(Size, Increment: integer);<br />
'''begin'''<br />
FSize := Size + 1;<br />
GetMem(FData, FSize);<br />
FIncrement := Increment;<br />
'''end''';<br />
<br />
==== Adding data ====<br />
<br />
First we check if there is enough room. If not then we reallocate memory. Then we add the data to our buffer. We need in practice a few overloaded methods here, see therefore the complete code example.<br />
<br />
'''procedure''' TMemBuilder.Add(P: PChar; Len: integer);<br />
'''begin'''<br />
'''if''' FLen + Len >= FSize '''then begin'''<br />
FSize := FSize + Max(Len, FIncrement) + 1;<br />
ReAllocMem(FData, FSize);<br />
'''end''';<br />
Move(P^, FData[FLen], Len);<br />
Inc(FLen, Len);<br />
FData[FLen] := #0;<br />
'''end''';<br />
<br />
==== Reading data ====<br />
<br />
Nothing can be more simple. We just have to public a property that point to the beginning of our data. In case it is binary data we need also a length property. If you want the data to be a string then you can do a typecast but think twice as this make an extra copy.<br />
<br />
'''property''' Data: PChar '''read''' FData;<br />
'''property''' Len: integer '''read''' FLen;<br />
<br />
==== Clearing the buffer ====<br />
<br />
We keep our memory for reuse, so all we need to do is reset the length.<br />
<br />
'''procedure''' TMemBuilder.Clear;<br />
'''begin'''<br />
FLen := 0;<br />
FData[0] := 0;<br />
'''end''';<br />
<br />
=== Complete class ===<br />
<br />
This is the complete class. You can copy / paste it to use it.<br />
<br />
'''unit''' uMemBuilder;<br />
<br />
'''interface'''<br />
<br />
'''type'''<br />
TMemBuilder = '''class'''<br />
'''private'''<br />
FSize: integer;<br />
FLen: integer;<br />
FIncrement: integer;<br />
FData: PChar;<br />
'''function''' Max(a, b: integer): integer;<br />
'''public'''<br />
'''constructor''' Create(Size, Increment: integer);<br />
'''destructor''' Destroy; '''override''';<br />
'''procedure''' Clear;<br />
'''procedure''' Add(S: '''string'''); '''overload''';<br />
'''procedure''' Add(P: PChar); '''overload''';<br />
'''procedure''' Add(P: PChar; Len: integer); '''overload''';<br />
'''property''' Data: PChar '''read''' FData;<br />
'''property''' Len: integer '''read''' FLen;<br />
end;<br />
<br />
'''implementation'''<br />
<br />
<font color="green"><i>{ TMemBuilder }</i></font><br />
<br />
'''procedure''' TMemBuilder.Add(S: '''string''');<br />
'''var'''<br />
Len: integer;<br />
'''begin'''<br />
Len := Length(S);<br />
Add(PChar(S), Len);<br />
'''end''';<br />
<br />
'''procedure''' TMemBuilder.Add(P: PChar);<br />
'''var'''<br />
Len: integer;<br />
'''begin'''<br />
Len := Length(P);<br />
Add(P, Len);<br />
'''end''';<br />
<br />
'''procedure''' TMemBuilder.Add(P: PChar; Len: integer);<br />
'''begin'''<br />
'''if''' FLen + Len >= FSize '''then''' '''begin'''<br />
FSize := FSize + Max(Len, FIncrement) + 1;<br />
ReAllocMem(FData, FSize);<br />
'''end''';<br />
Move(P^, FData[FLen], Len);<br />
Inc(FLen, Len);<br />
FData[FLen] := #0;<br />
'''end''';<br />
<br />
'''procedure''' TMemBuilder.Clear;<br />
'''begin'''<br />
FLen := 0;<br />
FData[FLen] := #0;<br />
'''end''';<br />
<br />
'''constructor''' TMemBuilder.Create(Size, Increment: integer);<br />
'''begin'''<br />
FSize := Size + 1;<br />
GetMem(FData, FSize);<br />
FIncrement := Increment;<br />
'''end''';<br />
<br />
'''destructor''' TMemBuilder.Destroy;<br />
'''begin'''<br />
FreeMem(FData);<br />
inherited;<br />
'''end''';<br />
<br />
'''function''' TMemBuilder.Max(a, b: integer): integer;<br />
'''begin'''<br />
'''if''' a >= b '''then'''<br />
Result := a<br />
'''else'''<br />
Result := b;<br />
'''end''';<br />
<br />
'''end'''.<br />
<br />
rgds, Wilfried<br />
http://www.mestdagh.biz</div>Wilfriedhttp://wiki.overbyte.eu/wiki/index.php?title=FAQ&diff=2012FAQ2006-05-01T13:15:11Z<p>Wilfried: /* FAQ */</p>
<hr />
<div>[[Main_Page | Main page]] -> [[FAQ]]<br />
<br />
<!--<br />
Here, you'll find the most Frequently Asked Questions about the components. Some links refer to articles and others on "How-to-do-things"<br />
--><br />
<br />
Here, you'll find the most frequently asked questions which cover a range of components or all. You will find questions specific to one component in the '''How to''' section of each component.<br />
<br />
== How ICS works ==<br />
{|<br />
| width="170" | [[Asynchronous_Paradigm | Asynchronous paradigm]] |||| The non-blocking nature of ICS.<br />
|-<br />
| [[Sending and receiving data]] |||| Draft discussing possible formats of data transfer.<br />
|}<br />
<br />
== FAQ ==<br />
{|<br />
| width="170" | [[FAQ.Concatenating data | Concatenating data]] |||| A example on how to concatenate chuncks of data in a CPU / Memory friendly way.<br />
|-<br />
| [[FAQ.General | General]] |||| General questions not belong to other section<br />
|-<br />
| [[FAQ.Internet | Internet]] |||| Specific for internet<br />
|-<br />
| [[FAQ.MultiThreading | Multi-Threading]] |||| Using ICS components and threads<br />
|-<br />
| [[FAQ.ProgressBar | Progress bar]] |||| Implementing a progress bar<br />
|-<br />
| [[FAQ.Timeout | Timeouts]] |||| Implementing timeouts on connections or protocols<br />
|}<br />
<br />
<!--<br />
* [[THttpCli.FAQ.Timeout | How to implement a timeout for THttpCli in my application?]]<br />
* [[THttpCli.FAQ.Progress | How to implement a progress for THttpCli in my application?]]<br />
* [[THttpCli.FAQ.SizeLimit | How to implement a download size limitation for THttpCli in my application?]]<br />
--></div>Wilfriedhttp://wiki.overbyte.eu/wiki/index.php?title=User:Wilfried&diff=2010User:Wilfried2006-04-14T16:34:15Z<p>Wilfried: </p>
<hr />
<div>== Drafts ==<br />
<br />
[[Concatenating data]]<br />
<br />
[[Thread article ideas]]<br />
<br />
[http://www.overbyte.be/frame_index.html?redirTo=/support/tcpudp_primer.html TCP / UDP Primer]<br />
<br />
[[Delimited data]]<br />
<br />
== Tests ==<br />
<br />
[[:Category:Cat | Cat]]</div>Wilfriedhttp://wiki.overbyte.eu/wiki/index.php?title=User:Wilfried&diff=2009User:Wilfried2006-04-14T16:32:55Z<p>Wilfried: </p>
<hr />
<div>== Drafts ==<br />
<br />
[[Concatenating data]]<br />
<br />
[[Thread article ideas]]<br />
<br />
[http://www.overbyte.be/frame_index.html?redirTo=/support/tcpudp_primer.html TCP / UDP Primer]<br />
<br />
[[LineMode]]<br />
<br />
[[Delimited data]]<br />
<br />
== Tests ==<br />
<br />
[[:Category:Cat | Cat]]</div>Wilfriedhttp://wiki.overbyte.eu/wiki/index.php?title=User:Wilfried&diff=2008User:Wilfried2006-04-14T16:30:22Z<p>Wilfried: </p>
<hr />
<div>== Drafts ==<br />
<br />
[[Concatenating data]]<br />
<br />
[[Thread article ideas]]<br />
<br />
[http://www.overbyte.be/frame_index.html?redirTo=/support/tcpudp_primer.html TCP / UDP Primer]<br />
<br />
[[LineMode]]<br />
<br />
[[Delimited data]]<br />
<br />
[[Endian]]<br />
<br />
== Tests ==<br />
<br />
[[:Category:Cat | Cat]]</div>Wilfriedhttp://wiki.overbyte.eu/wiki/index.php?title=User:Wilfried&diff=1999User:Wilfried2006-04-10T19:18:46Z<p>Wilfried: </p>
<hr />
<div>== Drafts ==<br />
<br />
[[Concatenating data]]<br />
<br />
[[Thread article ideas]]<br />
<br />
[[ProtoDesign | Designing a protocol]]<br />
<br />
[http://www.overbyte.be/frame_index.html?redirTo=/support/tcpudp_primer.html TCP / UDP Primer]<br />
<br />
[[LineMode]]<br />
<br />
[[Delimited data]]<br />
<br />
[[Endian]]<br />
<br />
== Tests ==<br />
<br />
[[:Category:Cat | Cat]]</div>Wilfriedhttp://wiki.overbyte.eu/wiki/index.php?title=User:Wilfried&diff=1939User:Wilfried2006-03-03T18:05:05Z<p>Wilfried: </p>
<hr />
<div>== Drafts ==<br />
<br />
[[Thread article ideas]]<br />
<br />
[[ProtoDesign | Designing a protocol]]<br />
<br />
[http://www.overbyte.be/frame_index.html?redirTo=/support/tcpudp_primer.html TCP / UDP Primer]<br />
<br />
[[LineMode]]<br />
<br />
[[Delimited data]]<br />
<br />
[[Endian]]<br />
<br />
== Tests ==<br />
<br />
[[:Category:Cat | Cat]]</div>Wilfriedhttp://wiki.overbyte.eu/wiki/index.php?title=FAQ.MultiThreading&diff=1933FAQ.MultiThreading2006-03-03T16:49:07Z<p>Wilfried: </p>
<hr />
<div>[[Main_Page | Main page]] -> [[FAQ]] -> [[FAQ.MultiThreading | MultiThreading]]<br />
<br />
== Introduction ==<br />
* What is a thread ?<br />
* What is multithreading ?<br />
* Advantages & Disadvantages<br />
<br />
== The Main Question ==<br />
Do i need Threads ?<br />
Cases where needed and where not needed<br />
<br />
== A Thread per Socket == <br />
When incoming connection, encapsulating socket within a thread, and managing communication within the thread, across several threads<br />
<br />
== A Worker Thread == <br />
When running a lengthy process (SQLing a RBDMS, doing bottlenecked I/O, ...), and to prevent GUI from freezing, encapsulating it in a thread (JobThread), and sending back data when the thread is done (or simulating a process end).</div>Wilfriedhttp://wiki.overbyte.eu/wiki/index.php?title=FAQ.Timeout&diff=1932FAQ.Timeout2006-03-03T16:47:46Z<p>Wilfried: </p>
<hr />
<div>[[Main_Page | Main page]] -> [[FAQ]] -> [[FAQ.Timeout | Timeout]]<br />
<br />
== Implementing a timeout ==<br />
<br />
Implementing a timeout with async socket is just a matter of testing since how long you haven't received a read request (OnDataAvailable event) from the remote site, or a write request (OnSendData), or a connect status (OnSessionConnected), or a disconnect status (OnSessionClosed) and so on.<br />
<br />
It is easy to implement timeouts at the application level using a simple and single TTimer for all timeouts. The idea is to have a list of timeout structures (to be created). This structure could be the time the last activity happened and a callback (a kind of event) to be called when the timeout occur. Of course each structure has to be updated each time some activity occurs.<br />
<br />
When the timer event is triggered, you scan the list to see the items having no activity since a given timeout, and then call their callback. From hte callback you do whatever action is needed, for example closing the connection.</div>Wilfriedhttp://wiki.overbyte.eu/wiki/index.php?title=Sending_and_receiving_data&diff=1902Sending and receiving data2006-02-27T09:32:30Z<p>Wilfried: /* Quoted-Printable */ add ctrl char like in the other paragraphs</p>
<hr />
<div>[[Main_Page | Main page]] -> [[FAQ]] -> [[Sending and receiving data]]<br />
<br />
== General ==<br />
<br />
There are several ways to transfer data. No matter if it is a file, an image, textual or raw data, it is all the same. What is needed is a common language between the data sender and the data receiver, in order for each to understand the other. This language defines a format. Formatting data is a way to "shape" it, describing its beginning and its end, in order for the receiver to know where data starts and ends.<br />
<br />
<!--<br />
We use the term ''binary data'' not to make a difference to ''ASCII'' or human readable data, but for data that has an unpredictable content, meaning we cannot use line mode just like that because whatever combination of characters you choose it ''could'' be in the data stream itself.<br />
<br />
== Solutions ==<br />
--><br />
<br />
Many formats are of course possible, mainly depending upon the kind of data itself. Basically, we can consider that we have two kinds of data :<br />
* predictable data content<br />
* unpredictable data content<br />
<br />
In the first case, we know what kind of content the data contains - ie the byte set that can be used is known (byte values from 32 to 127, for example). In the other case, the data content is not known - ie the byte set can be any possible byte value (from 0 to 255). This major difference will mostly determine the format of the data to be exchanged, defining then the protocol.<br />
<br />
Concerning Predictable Data Content, as the content values are known by advance - a subset of the 256 possible byte values, it is possible to know which byte values '''cannot''' be part of the data. This hint let us the possibility to create a delimiter made of one or more of these "extra data" byte values. This delimiter, sent after data, may then help us to know where data ends. This mode where a delimiter is placed at the end of data is named LineMode.<br />
<br />
Concerning Unpredictable Data Content, as the content values are never known by advance - byte set values starts at 0 and ends at 255, if we plan to send several data packet (for example several records) at once, then we have to tell the receiver the size of the data we're going to send for each packet. This mode to "format" data packet by prefixing it with its size is call PacketMode.<br />
<br />
And if we plan to send at the same time some Predictable Data Content and some Unpredictable Data Content, we can then imagine a combination of both mode.<br />
<br />
[[TWSocket]] has the ability to help you in implementing such a protocol. It is able to manage data using [[TWSocket.LineMode | LineMode]] and PacketMode (which is Non-LineMode).<br />
<br />
== Line mode ==<br />
<br />
Line mode is the most widely used, specially with ''ascii'' based protocols. But there are many protocols where line mode is used with unpredictable data. In that case that data has to converted into a specific range of bytes. The most used encoding mechanism are described here.<br />
<br />
=== Base-64 ===<br />
<br />
''Base64'' is an encoding process using a 64 letter alphabet where each letter representing 6 bits in the input stream. It is described in RFC [http://rfc.net/rfc2045.html#p24 2045]. All encoding and decoding procedures can be found in unit MimeUtil. The encoded data is about 33 percent larger and not human readable. Every character not used in the Base64 alphabet can be used as control character, including line end.<br />
<br />
=== ASCII-hex ===<br />
<br />
''ASCII-hex'' is used in many protocols. Every character is converted into his hexadecimal equivalent and sent as such. For example the string '123' is sent as '313233'. The encoded data is twice as long and difficult human readable. Every character except 0..9, A..F can be used as control character, including line end.<br />
<br />
=== Escaping ===<br />
<br />
Escaping is very often used. Control characters including line end has to be chosen in a way they are as less as possible in the original data. The principle is to precede the control characters with an escape character and replace them by other characters. Very often a NULL character is escaped as well. Most of the time the encoded data is only a little longer than original and good human readable.<br />
<br />
=== Quoted-Printable ===<br />
<br />
The Quoted-Printable encoding as specified in RFC [http://RFC.net/rfc1521.html#p18 1521] is intended to represent data which is largely human readable. It encodes certain byte ranges into their hexadecimal presentation. The encoded data remains good human readable. Procedures to encode and decode Quoted-Printable can be found in unit MimeUtil. Every encoded character can be used as control character, including line end.<br />
<br />
<!--<br />
The Quoted-Printable encoding as specified in RFC [http://RFC.net/rfc1521.html#p18 1521] is intended to represent data that largely consists of bytes that correspond to printable characters in the ASCII character set. It encodes the data in such a way that the resulting bytes are unlikely to be modified by mail transport. If the data being encoded are mostly ASCII text, the encoded form of the data remains largely recognizable by humans. Procedures to encode and decode Quoted-Printable can be found in unit MimeUtil.<br />
--><br />
<br />
== Packet mode ==<br />
<br />
Packet mode is also very widely used and most of the time designed for a specific protocol. In packet mode the data has a specific structure which eventually can be different depending on the type of packet even within the same protocol. The most universal ones are explained here.<br />
<br />
=== Header ===<br />
<br />
A very often used technique is to precede the data with a header. Presides other control information this header has a field containing the length of the data.<br />
<br />
The length field is 1, 2 or 4 bytes long. Note that it is common habitude in communications to represent numbers in [[Endian | Big Endian]] format while Intel CPU use by design [[Endian | Little Endian]] format.<br />
<br />
Less used but also a very good technique is to represent the length field in hexadecimal format of 2, 4 or 8 bytes. Advantage is that it is human readable.<br />
<br />
=== Fixed length data ===<br />
<br />
Fixed length data is where all packets of the same type have the same structure and length. Mostly the type of the structure is indicated in a field somewhere at the beginning. If such a structure contains a data field of variable length then eater the data is padded or its length is indicated in a field in the structure.<br />
<br />
== Mixed mode ==<br />
<br />
[[TWSocket]] has the ability to implement a mixed mode protocol by switching [[TWSocket.LineMode | LineMode]] during negotiation.<br />
<br />
=== Example ===<br />
<br />
* ''A'' want to send data, so he tell it to ''B'' during negotiation, with ''ascii'' commands using [[TWSocket.LineMode | LineMode]], including the size.<br />
* After receiving that information, ''B'' switch [[TWSocket.LineMode | LineMode]] off then tell it to ''A''.<br />
* When ''A'' receive this confirmation it start sending exact what has negotiated.<br />
* When ''B'' has received it all, then he switch [[TWSocket.LineMode | LineMode]] back on then tell it to ''A''.<br />
* After receiving that information both are again in negotiation phase.<br />
<br />
== Conclusion ==<br />
<br />
Difficult to explain something :)<br />
<br />
<br />
[[User:Wilfried|Wilfried]] 20:18, 21 February 2006 (CET)</div>Wilfriedhttp://wiki.overbyte.eu/wiki/index.php?title=TWSocket&diff=1901TWSocket2006-02-26T20:26:01Z<p>Wilfried: /* Methods */</p>
<hr />
<div>[[Main_Page | Main page]] -> [[ICS_Components_Reference | ICS component reference]] -> [[TWSocket]]<br />
== Overview ==<br />
<br />
{|<br />
| '''unit''' |||| WSocket.pas<br />
|-<br />
| '''inheritance''' ||||<br />
|}<br />
<br />
TWSocket component is implementing the TCP protocol described in RFC [http://rfc.net/rfc793.html 793] and and UDP protocol described in RFC [http://rfc.net/rfc768.html 768]. Both protocols are encaptulated by the IP protocol described in RFC [http://rfc.net/rfc791.html 791]. TWSocket is used in almost every other ICS component.<br />
<br />
TWSocket component can be used as client or a server. For its use as TCP server however [[TWSocketServer]] is encouraged because of his advanced features.<br />
<br />
== Properties ==<br />
<br />
{| <br />
| width="140" valign="top" | [[TWSocket.Addr | Addr]] |||| ''Client:'' The host to connect to. ''Server:'' The interface to listen on.<br />
|-<br />
| valign="top" | [[TWSocket.AllSent | AllSent]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.BufSize | BufSize]] |||| Size in bytes for dynamic send buffer cells.<br />
|-<br />
| valign="top" | [[TWSocket.ComponentOptions | ComponentOptions]] |||| Used to modify how the component handle some operations.<br />
|-<br />
| valign="top" | [[TWSocket.DnsResult | DnsResult]] |||| Typically called in [[TWSocket.OnDnsLookupDone | OnDnsLookupDone]]. The IP address of the remote host given as argument to [[TWSocket.DnsLookup | DnsLookup]].<br />
|-<br />
| valign="top" | [[TWSocket.DnsResultList | DnsResultList]] |||| Similar to [[TWSocket.DnsResult | DnsResult]] but a TStringList containing the multiple IP's of the host if appropriate.<br />
|-<br />
| valign="top" | [[TWSocket.Handle | Handle]] |||| Handle for the underlaying hidden window.<br />
|-<br />
| valign="top" | [[TWSocket.HSocket | HSocket]] |||| Winsock handle for underlaying socket.<br />
|-<br />
| valign="top" | [[TWSocket.IcsLogger | IcsLogger]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LastError | LastError]] |||| Save the last error occured during socket operation.<br />
|-<br />
| valign="top" | [[TWSocket.LineEcho | LineEcho]] |||| Echo all received characters back to tramitter.<br />
|-<br />
| valign="top" | [[TWSocket.LineEdit | LineEdit]] |||| Handle received control characters used for editing.<br />
|-<br />
| valign="top" | [[TWSocket.LineEnd | LineEnd]] |||| End of line character(s) used ot trigger [[TWSocket.OnDataAvailable | OnDataAvailable]].<br />
|-<br />
| valign="top" | [[TWSocket.LineLength | LineLength]] |||| When using LineMode: the length of the received line.<br />
|-<br />
| valign="top" | [[TWSocket.LineLimit | LineLimit]] |||| Maximum line lenght to receive before triggering [[TWSocket.OnLineLimitExceeded | OnLineLimitExceeded]]. See also [[DOS attac]].<br />
|-<br />
| valign="top" | [[TWSocket.LineMode | LineMode]] |||| Use [[TWSocket.LineEnd | LineEnd]] as end of line marker to trigger [[TWSocket.OnDataAvailable | OnDataAvailable]].<br />
|-<br />
| valign="top" | [[TWSocket.LingerOnOff | LingerOnOff]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LingerTimeout | LingerTimeout]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ListenBacklog | ListenBacklog]] |||| Size of pending connection queue in server mode.<br />
|-<br />
| valign="top" | [[TWSocket.LocalAddr | LocalAddr]] |||| The local address where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.LocalPort | LocalPort]] |||| The local port where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.MultiCast | MultiCast]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MultiCastAddrStr | MultiCastAddrStr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MultiCastIpTTL | MultiCastIpTTL]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MultiThreaded | MultiThreaded]] |||| Set when TWSocket has to use his own message pump.<br />
|-<br />
| valign="top" | [[TWSocket.PeerAddr | PeerAddr]] |||| The remote address where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.PeerPort | PeerPort]] |||| The remote port port where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.Port | Port]] |||| ''Client:'' The port to connect to. ''Server:'' The port to listen on.<br />
|-<br />
| width="90" valign="top" | [[TWSocket.PortNum | PortNum]] |||| Integer value of [[TWSocket.Port | Port]].<br />
|-<br />
| valign="top" | [[TWSocket.Proto | Proto]] |||| The protocol to use, can be '''tcp''' or '''tcp'''.<br />
|-<br />
| valign="top" | [[TWSocket.RcvdCnt | RcvdCnt]] |||| Number of character received in internal buffer when using line mode.<br />
|-<br />
| valign="top" | [[TWSocket.RcvdCount | RcvdCount]] |||| Number of characters in receive buffer but not read yet.<br />
|-<br />
| valign="top" | [[TWSocket.RcvdPtr | RcvdPtr]] |||| Internal rceive buffer pointer used for line mode.<br />
|-<br />
| valign="top" | [[TWSocket.ReadCount | ReadCount]] |||| Total number of bytes received.<br />
|-<br />
| valign="top" | [[TWSocket.ReqVerLow | ReqVerLow]] |||| Low part of winsock version to load.<br />
|-<br />
| valign="top" | [[TWSocket.ReqVerHigh | ReqVerHigh]] |||| High part of winsock version to load.<br />
|-<br />
| valign="top" | [[TWSocket.ReuseAddr | ReuseAddr]] |||| Should the compnent try to reuse an address.<br />
|-<br />
| valign="top" | [[TWSocket.SendFlags | SendFlags]] |||| How to send data.<br />
|-<br />
| valign="top" | [[TWSocket.SocksAuthentication | SocksAuthentication]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksLevel | SocksLevel]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksPassword | SocksPassword]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksPort | SocksPort]] |||| Port number for socks server.<br />
|-<br />
| valign="top" | [[TWSocket.SocksServer | SocksServer]] |||| IP or hostname for socks server.<br />
|-<br />
| valign="top" | [[TWSocket.SocksUsercode | SocksUsercode]] |||| Usercode for socks server authentication.<br />
|-<br />
| valign="top" | [[TWSocket.State | State]] |||| Current state of the socket, mainly used for log or display purposes.<br />
|-<br />
| valign="top" | [[TWSocket.Terminated | Terminated]] |||| To be set to terminate synchronous operation prematurely.<br />
|-<br />
| valign="top" | [[TWSocket.Text | Text]] |||| Equivalent to ReceiveStr and SendStr.<br />
|}<br />
<br />
== Methods ==<br />
<br />
{| <br />
| width="140" valign="top" | [[TWSocket.Abort | Abort]] |||| Quick and dirty way to close the socket.<br />
|-<br />
| valign="top" | [[TWSocket.Accept | Accept]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.CancelDnsLookup | CancelDnsLookup]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Close | Close]] |||| Close the socket gracefull.<br />
|-<br />
| valign="top" | [[TWSocket.CloseDelayed | CloseDelayed]] |||| Close the socket gracefull in a message handler.<br />
|-<br />
| valign="top" | [[TWSocket.Connect | Connect]] |||| Connect to a remote host.<br />
|-<br />
| valign="top" | [[TWSocket.Create | Create]] |||| Dynamcly create the component.<br />
|-<br />
| valign="top" | [[TWSocket.DeleteBufferedData | DeleteBufferedData]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Destroy | Destroy]] |||| Destroy the dynamicly created component.<br />
|-<br />
| valign="top" | [[TWSocket.DnsLookup | DnsLookup]] |||| Perform a DNS lookup of a hostname in background. See also [[TWSocket.OnDNSLookupDone | OnDNSLookupDone]].<br />
|-<br />
| valign="top" | [[TWSocket.Dup | Dup]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Flush | Flush]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetPeerAddr | GetPeerAddr]] |||| Returns the remote address where the socket has been bound. See also [[TWSocket.PeerAddr | PeerAddr]].<br />
|-<br />
| valign="top" | [[TWSocket.GetPeerName | GetPeerName]] |||| Returns the remot hostname where the socket has been bound.<br />
|-<br />
| valign="top" | [[TWSocket.GetPeerPort | GetPeerPort]] |||| Returns the remote port where the socket has been bound. See also [[TWSocket.PeerPort | PeerPort]].<br />
|-<br />
| valign="top" | [[TWSocket.GetSockName | GetSockName]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetXAddr | GetXAddr]] |||| Returns the local interface to where the socket has been bound.<br />
|-<br />
| valign="top" | [[TWSocket.GetXPort | GetXPort]] |||| Returns the local port to where the socket has been bound.<br />
|-<br />
| valign="top" | [[TWSocket.Listen | Listen]] |||| Set the socket in listening state to accept inbound connections.<br />
|-<br />
| valign="top" | [[TWSocket.MessageLoop | MessageLoop]] |||| Pump messages until WM_QUIT is received.<br />
|-<br />
| valign="top" | [[TWSocket.MessagePump | MessagePump]] |||| Trigger [[TWSocket.OnMessagePump | OnMessagePump]] or call [[TWSocket.ProcessMessages | ProcessMessages]].<br />
|-<br />
| valign="top" | [[TWSocket.Pause | Pause]] |||| Stop delivery notification of received TCP data.<br />
|-<br />
| valign="top" | [[TWSocket.PeekData | PeekData]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ProcessMessage | ProcessMessage]] |||| Similar as TApplication.ProcessMessage.<br />
|-<br />
| valign="top" | [[TWSocket.ProcessMessages | ProcessMessages]] |||| Similar as TApplication.ProcessMessages.<br />
|-<br />
| valign="top" | [[TWSocket.PutDataInSendBuffer | PutDataInSendBuffer]] |||| Put data in send buffer without sending it.<br />
|-<br />
| valign="top" | [[TWSocket.PutStringInSendBuffer | PutStringInSendBuffer]] |||| Put string in send buffer without sending it.<br />
|-<br />
| valign="top" | [[TWSocket.Receive | Receive]] |||| Receive data in [[TWSocket.OnDataAvailable | OnDataAvailable]].<br />
|-<br />
| valign="top" | [[TWSocket.ReceiveFrom | ReceiveFrom]] |||| <br />
|-<br />
| valign="top" | [[TWSocket.ReceiveStr | ReceiveStr]] |||| Receive string in [[TWSocket.OnDataAvailable | OnDataAvailable]].<br />
|-<br />
| valign="top" | [[TWSocket.Release | Release]] |||| Destroy the dynamicly created TWSocket in a custom message handler.<br />
|-<br />
| valign="top" | [[TWSocket.Resume | Resume]] |||| Resume delivery notification for received data.<br />
|-<br />
| valign="top" | [[TWSocket.ReverseDnsLookup | ReverseDnsLookup]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Send | Send]] |||| Send data.<br />
|-<br />
| valign="top" | [[TWSocket.SendStr | SendStr]] |||| Send a string.<br />
|-<br />
| valign="top" | [[TWSocket.SendTo | SendTo]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SetLingerOption | SetLingerOption]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Shutdown | Shutdown]] |||| Close the socket gracefull.<br />
|-<br />
| valign="top" | [[TWSocket.TimerClear | TimerClear]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.TimerCmp | TimerCmp]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.TimerIsSet | TimerIsSet]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ThreadAttach | ThreadAttach]] |||| Attach the hidden window to a thread.<br />
|-<br />
| valign="top" | [[TWSocket.ThreadDetach | ThreadDetach]] |||| Detach the hidden window from a thread.<br />
|-<br />
| valign="top" | [[TWSocket.WaitForClose | WaitForClose]] ||||<br />
|}<br />
<br />
== Events ==<br />
<br />
{|<br />
| width="140" valign="top" | [[TWSocket.OnBgException | OnBgException]] |||| Background exception occured.<br />
|-<br />
| valign="top" | [[TWSocket.OnChangeState | OnChangeState]] |||| State of TWSocket has changed.<br />
|-<br />
| valign="top" | [[TWSocket.OnDataAvailable | OnDataAvailable]] |||| Data available in internal receive buffer.<br />
|-<br />
| valign="top" | [[TWSocket.OnDataSent | OnDataSent]] |||| Internal sent buffer is completely delivered to winsock.<br />
|-<br />
| width="90" valign="top" | [[TWSocket.OnDebugDisplay | OnDebugDisplay]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.OnDnsLookupDone | OnDnsLookupDone]] |||| [[TWSocket.DNSLookup | DNSLookup]] has finished.<br />
|-<br />
| valign="top" | [[TWSocket.OnError | OnError]] |||| ''Discouraged'', use exception handling instead.<br />
|-<br />
| valign="top" | [[TWSocket.OnLineLimitExceeded | OnLineLimitExceeded]] |||| Denial of service attack<br />
|-<br />
| valign="top" | [[TWSocket.OnMessagePump | OnMessagePump]] |||| To call your own message pump.<br />
|-<br />
| valign="top" | [[TWSocket.OnSendData | OnSendData]] |||| Winsock send buffer is empty, will be filled again by internal send buffer if still data available to send.<br />
|-<br />
| valign="top" | [[TWSocket.OnSessionAvailable | OnSessionAvailable]] |||| Client connected to this server.<br />
|-<br />
| valign="top" | [[TWSocket.OnSessionClosed | OnSessionClosed]] |||| Socket has closed.<br />
|-<br />
| valign="top" | [[TWSocket.OnSessionConnected | OnSessionConnected]] |||| Session to host etablished.<br />
|-<br />
| valign="top" | [[TWSocket.OnSocksAuthState | OnSocksAuthState]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.OnSocksConnected | OnSocksConnected]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.OnSocksError | OnSocksError]] ||||<br />
|}<br />
<br />
== How to ==<br />
<br />
* [[TWSocket.HowTo.Close | Close a TCP session]]<br />
* [[TWSocket.HowTo.Close | Destroy a dynamicly created TWSocket]]<br />
<br />
{{Components_Footer}}</div>Wilfriedhttp://wiki.overbyte.eu/wiki/index.php?title=TWSocket&diff=1900TWSocket2006-02-26T20:25:13Z<p>Wilfried: /* Methods */</p>
<hr />
<div>[[Main_Page | Main page]] -> [[ICS_Components_Reference | ICS component reference]] -> [[TWSocket]]<br />
== Overview ==<br />
<br />
{|<br />
| '''unit''' |||| WSocket.pas<br />
|-<br />
| '''inheritance''' ||||<br />
|}<br />
<br />
TWSocket component is implementing the TCP protocol described in RFC [http://rfc.net/rfc793.html 793] and and UDP protocol described in RFC [http://rfc.net/rfc768.html 768]. Both protocols are encaptulated by the IP protocol described in RFC [http://rfc.net/rfc791.html 791]. TWSocket is used in almost every other ICS component.<br />
<br />
TWSocket component can be used as client or a server. For its use as TCP server however [[TWSocketServer]] is encouraged because of his advanced features.<br />
<br />
== Properties ==<br />
<br />
{| <br />
| width="140" valign="top" | [[TWSocket.Addr | Addr]] |||| ''Client:'' The host to connect to. ''Server:'' The interface to listen on.<br />
|-<br />
| valign="top" | [[TWSocket.AllSent | AllSent]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.BufSize | BufSize]] |||| Size in bytes for dynamic send buffer cells.<br />
|-<br />
| valign="top" | [[TWSocket.ComponentOptions | ComponentOptions]] |||| Used to modify how the component handle some operations.<br />
|-<br />
| valign="top" | [[TWSocket.DnsResult | DnsResult]] |||| Typically called in [[TWSocket.OnDnsLookupDone | OnDnsLookupDone]]. The IP address of the remote host given as argument to [[TWSocket.DnsLookup | DnsLookup]].<br />
|-<br />
| valign="top" | [[TWSocket.DnsResultList | DnsResultList]] |||| Similar to [[TWSocket.DnsResult | DnsResult]] but a TStringList containing the multiple IP's of the host if appropriate.<br />
|-<br />
| valign="top" | [[TWSocket.Handle | Handle]] |||| Handle for the underlaying hidden window.<br />
|-<br />
| valign="top" | [[TWSocket.HSocket | HSocket]] |||| Winsock handle for underlaying socket.<br />
|-<br />
| valign="top" | [[TWSocket.IcsLogger | IcsLogger]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LastError | LastError]] |||| Save the last error occured during socket operation.<br />
|-<br />
| valign="top" | [[TWSocket.LineEcho | LineEcho]] |||| Echo all received characters back to tramitter.<br />
|-<br />
| valign="top" | [[TWSocket.LineEdit | LineEdit]] |||| Handle received control characters used for editing.<br />
|-<br />
| valign="top" | [[TWSocket.LineEnd | LineEnd]] |||| End of line character(s) used ot trigger [[TWSocket.OnDataAvailable | OnDataAvailable]].<br />
|-<br />
| valign="top" | [[TWSocket.LineLength | LineLength]] |||| When using LineMode: the length of the received line.<br />
|-<br />
| valign="top" | [[TWSocket.LineLimit | LineLimit]] |||| Maximum line lenght to receive before triggering [[TWSocket.OnLineLimitExceeded | OnLineLimitExceeded]]. See also [[DOS attac]].<br />
|-<br />
| valign="top" | [[TWSocket.LineMode | LineMode]] |||| Use [[TWSocket.LineEnd | LineEnd]] as end of line marker to trigger [[TWSocket.OnDataAvailable | OnDataAvailable]].<br />
|-<br />
| valign="top" | [[TWSocket.LingerOnOff | LingerOnOff]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LingerTimeout | LingerTimeout]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ListenBacklog | ListenBacklog]] |||| Size of pending connection queue in server mode.<br />
|-<br />
| valign="top" | [[TWSocket.LocalAddr | LocalAddr]] |||| The local address where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.LocalPort | LocalPort]] |||| The local port where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.MultiCast | MultiCast]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MultiCastAddrStr | MultiCastAddrStr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MultiCastIpTTL | MultiCastIpTTL]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MultiThreaded | MultiThreaded]] |||| Set when TWSocket has to use his own message pump.<br />
|-<br />
| valign="top" | [[TWSocket.PeerAddr | PeerAddr]] |||| The remote address where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.PeerPort | PeerPort]] |||| The remote port port where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.Port | Port]] |||| ''Client:'' The port to connect to. ''Server:'' The port to listen on.<br />
|-<br />
| width="90" valign="top" | [[TWSocket.PortNum | PortNum]] |||| Integer value of [[TWSocket.Port | Port]].<br />
|-<br />
| valign="top" | [[TWSocket.Proto | Proto]] |||| The protocol to use, can be '''tcp''' or '''tcp'''.<br />
|-<br />
| valign="top" | [[TWSocket.RcvdCnt | RcvdCnt]] |||| Number of character received in internal buffer when using line mode.<br />
|-<br />
| valign="top" | [[TWSocket.RcvdCount | RcvdCount]] |||| Number of characters in receive buffer but not read yet.<br />
|-<br />
| valign="top" | [[TWSocket.RcvdPtr | RcvdPtr]] |||| Internal rceive buffer pointer used for line mode.<br />
|-<br />
| valign="top" | [[TWSocket.ReadCount | ReadCount]] |||| Total number of bytes received.<br />
|-<br />
| valign="top" | [[TWSocket.ReqVerLow | ReqVerLow]] |||| Low part of winsock version to load.<br />
|-<br />
| valign="top" | [[TWSocket.ReqVerHigh | ReqVerHigh]] |||| High part of winsock version to load.<br />
|-<br />
| valign="top" | [[TWSocket.ReuseAddr | ReuseAddr]] |||| Should the compnent try to reuse an address.<br />
|-<br />
| valign="top" | [[TWSocket.SendFlags | SendFlags]] |||| How to send data.<br />
|-<br />
| valign="top" | [[TWSocket.SocksAuthentication | SocksAuthentication]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksLevel | SocksLevel]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksPassword | SocksPassword]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksPort | SocksPort]] |||| Port number for socks server.<br />
|-<br />
| valign="top" | [[TWSocket.SocksServer | SocksServer]] |||| IP or hostname for socks server.<br />
|-<br />
| valign="top" | [[TWSocket.SocksUsercode | SocksUsercode]] |||| Usercode for socks server authentication.<br />
|-<br />
| valign="top" | [[TWSocket.State | State]] |||| Current state of the socket, mainly used for log or display purposes.<br />
|-<br />
| valign="top" | [[TWSocket.Terminated | Terminated]] |||| To be set to terminate synchronous operation prematurely.<br />
|-<br />
| valign="top" | [[TWSocket.Text | Text]] |||| Equivalent to ReceiveStr and SendStr.<br />
|}<br />
<br />
== Methods ==<br />
<br />
{| <br />
| width="140" valign="top" | [[TWSocket.Abort | Abort]] |||| Quick and dirty way to close the socket.<br />
|-<br />
| valign="top" | [[TWSocket.Accept | Accept]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.CancelDnsLookup | CancelDnsLookup]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Close | Close]] |||| Close the socket gracefull.<br />
|-<br />
| valign="top" | [[TWSocket.CloseDelayed | CloseDelayed]] |||| Close the socket gracefull in a message handler.<br />
|-<br />
| valign="top" | [[TWSocket.Connect | Connect]] |||| Connect to a remote host.<br />
|-<br />
| valign="top" | [[TWSocket.Create | Create]] |||| Dynamcly create the component.<br />
|-<br />
| valign="top" | [[TWSocket.DeleteBufferedData | DeleteBufferedData]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Destroy | Destroy]] |||| Destroy the dynamicly created component.<br />
|-<br />
| valign="top" | [[TWSocket.DnsLookup | DnsLookup]] |||| Perform a DNS lookup of a hostname in background. See also [[TWSocket.OnDNSLookupDone | OnDNSLookupDone]].<br />
|-<br />
| valign="top" | [[TWSocket.Dup | Dup]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Flush | Flush]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetPeerAddr | GetPeerAddr]] |||| Returns the remote address where the socket has been bound. See also [[TWSocket.PeerAddr | PeerAddr]].<br />
|-<br />
| valign="top" | [[TWSocket.GetPeerName | GetPeerName]] |||| Returns the remot hostname where the socket has been bound.<br />
|-<br />
| valign="top" | [[TWSocket.GetPeerPort | GetPeerPort]] |||| Returns the remote port where the socket has been bound. See also [[TWSocket.PeerPort | PeerPort]].<br />
|-<br />
| valign="top" | [[TWSocket.GetSockName | GetSockName]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetXAddr | GetXAddr]] |||| Returns the local interface to where the socket has been bound.<br />
|-<br />
| valign="top" | [[TWSocket.GetXPort | GetXPort]] |||| Returns the local port to where the socket has been bound.<br />
|-<br />
| valign="top" | [[TWSocket.Listen | Listen]] |||| Set the socket in listening state to accept inbound connections.<br />
|-<br />
| valign="top" | [[TWSocket.MessageLoop | MessageLoop]] |||| Pump messages until WM_QUIT is received.<br />
|-<br />
| valign="top" | [[TWSocket.MessagePump | MessagePump]] |||| Trigger [[TWSocket.OnMessagePump | OnMessagePump]] or call [[TWSocket.ProcessMessages | ProcessMessages]].<br />
|-<br />
| valign="top" | [[TWSocket.Pause | Pause]] |||| Stop delivery notification of received TCP data.<br />
|-<br />
| valign="top" | [[TWSocket.PeekData | PeekData]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ProcessMessage | ProcessMessage]] |||| Similar as TApplication.ProcessMessage.<br />
|-<br />
| valign="top" | [[TWSocket.ProcessMessages | ProcessMessages]] |||| Similar as TApplication.ProcessMessages.<br />
|-<br />
| valign="top" | [[TWSocket.PutDataInSendBuffer | PutDataInSendBuffer]] |||| Put data in send buffer without sending it.<br />
|-<br />
| valign="top" | [[TWSocket.PutStringInSendBuffer | PutStringInSendBuffer]] |||| Put string in send buffer without sending it.<br />
|-<br />
| valign="top" | [[TWSocket.Receive | Receive]] |||| Receive data in [[TWSocket.OnDataAvailable | OnDataAvailable]].<br />
|-<br />
| valign="top" | [[TWSocket.ReceiveFrom | ReceiveFrom]] |||| <br />
|-<br />
| valign="top" | [[TWSocket.ReceiveStr | ReceiveStr]] |||| Receive string in [[TWSocket.OnDataAvailable | OnDataAvailable]].<br />
|-<br />
| valign="top" | [[TWSocket.Release | Release]] |||| Destroy the dynamicly created TWSocket in a custom message handler.<br />
|-<br />
| valign="top" | [[TWSocket.Resume | Resume]] |||| Resume delivery notification for received data.<br />
|-<br />
| valign="top" | [[TWSocket.ReverseDnsLookup | ReverseDnsLookup]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Send | Send]] |||| Send data.<br />
|-<br />
| valign="top" | [[TWSocket.SendStr | SendStr]] |||| Send a string.<br />
|-<br />
| valign="top" | [[TWSocket.SendTo | SendTo]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SetLingerOption | SetLingerOption]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Shutdown | Shutdown]] |||| Close the socket gracefull.<br />
|-<br />
| valign="top" | [[TWSocket.TimerClear | TimerClear]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.TimerCmp | TimerCmp]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.TimerIsSet | TimerIsSet]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ThreadAttach | ThreadAttach]] |||| Attach the hidden window to a thread.<br />
|-<br />
| valign="top" | [[TWSocket.ThreadDetach | ThreadDetach]] |||| Detach the hidden window from a thread.<br />
|-<br />
| valign="top" | [[TWSocket.WaitForClose | WaitForClose]] |||| Wilfried What is this ?<br />
|}<br />
<br />
== Events ==<br />
<br />
{|<br />
| width="140" valign="top" | [[TWSocket.OnBgException | OnBgException]] |||| Background exception occured.<br />
|-<br />
| valign="top" | [[TWSocket.OnChangeState | OnChangeState]] |||| State of TWSocket has changed.<br />
|-<br />
| valign="top" | [[TWSocket.OnDataAvailable | OnDataAvailable]] |||| Data available in internal receive buffer.<br />
|-<br />
| valign="top" | [[TWSocket.OnDataSent | OnDataSent]] |||| Internal sent buffer is completely delivered to winsock.<br />
|-<br />
| width="90" valign="top" | [[TWSocket.OnDebugDisplay | OnDebugDisplay]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.OnDnsLookupDone | OnDnsLookupDone]] |||| [[TWSocket.DNSLookup | DNSLookup]] has finished.<br />
|-<br />
| valign="top" | [[TWSocket.OnError | OnError]] |||| ''Discouraged'', use exception handling instead.<br />
|-<br />
| valign="top" | [[TWSocket.OnLineLimitExceeded | OnLineLimitExceeded]] |||| Denial of service attack<br />
|-<br />
| valign="top" | [[TWSocket.OnMessagePump | OnMessagePump]] |||| To call your own message pump.<br />
|-<br />
| valign="top" | [[TWSocket.OnSendData | OnSendData]] |||| Winsock send buffer is empty, will be filled again by internal send buffer if still data available to send.<br />
|-<br />
| valign="top" | [[TWSocket.OnSessionAvailable | OnSessionAvailable]] |||| Client connected to this server.<br />
|-<br />
| valign="top" | [[TWSocket.OnSessionClosed | OnSessionClosed]] |||| Socket has closed.<br />
|-<br />
| valign="top" | [[TWSocket.OnSessionConnected | OnSessionConnected]] |||| Session to host etablished.<br />
|-<br />
| valign="top" | [[TWSocket.OnSocksAuthState | OnSocksAuthState]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.OnSocksConnected | OnSocksConnected]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.OnSocksError | OnSocksError]] ||||<br />
|}<br />
<br />
== How to ==<br />
<br />
* [[TWSocket.HowTo.Close | Close a TCP session]]<br />
* [[TWSocket.HowTo.Close | Destroy a dynamicly created TWSocket]]<br />
<br />
{{Components_Footer}}</div>Wilfriedhttp://wiki.overbyte.eu/wiki/index.php?title=TWSocket&diff=1899TWSocket2006-02-26T20:22:09Z<p>Wilfried: /* Methods */</p>
<hr />
<div>[[Main_Page | Main page]] -> [[ICS_Components_Reference | ICS component reference]] -> [[TWSocket]]<br />
== Overview ==<br />
<br />
{|<br />
| '''unit''' |||| WSocket.pas<br />
|-<br />
| '''inheritance''' ||||<br />
|}<br />
<br />
TWSocket component is implementing the TCP protocol described in RFC [http://rfc.net/rfc793.html 793] and and UDP protocol described in RFC [http://rfc.net/rfc768.html 768]. Both protocols are encaptulated by the IP protocol described in RFC [http://rfc.net/rfc791.html 791]. TWSocket is used in almost every other ICS component.<br />
<br />
TWSocket component can be used as client or a server. For its use as TCP server however [[TWSocketServer]] is encouraged because of his advanced features.<br />
<br />
== Properties ==<br />
<br />
{| <br />
| width="140" valign="top" | [[TWSocket.Addr | Addr]] |||| ''Client:'' The host to connect to. ''Server:'' The interface to listen on.<br />
|-<br />
| valign="top" | [[TWSocket.AllSent | AllSent]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.BufSize | BufSize]] |||| Size in bytes for dynamic send buffer cells.<br />
|-<br />
| valign="top" | [[TWSocket.ComponentOptions | ComponentOptions]] |||| Used to modify how the component handle some operations.<br />
|-<br />
| valign="top" | [[TWSocket.DnsResult | DnsResult]] |||| Typically called in [[TWSocket.OnDnsLookupDone | OnDnsLookupDone]]. The IP address of the remote host given as argument to [[TWSocket.DnsLookup | DnsLookup]].<br />
|-<br />
| valign="top" | [[TWSocket.DnsResultList | DnsResultList]] |||| Similar to [[TWSocket.DnsResult | DnsResult]] but a TStringList containing the multiple IP's of the host if appropriate.<br />
|-<br />
| valign="top" | [[TWSocket.Handle | Handle]] |||| Handle for the underlaying hidden window.<br />
|-<br />
| valign="top" | [[TWSocket.HSocket | HSocket]] |||| Winsock handle for underlaying socket.<br />
|-<br />
| valign="top" | [[TWSocket.IcsLogger | IcsLogger]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LastError | LastError]] |||| Save the last error occured during socket operation.<br />
|-<br />
| valign="top" | [[TWSocket.LineEcho | LineEcho]] |||| Echo all received characters back to tramitter.<br />
|-<br />
| valign="top" | [[TWSocket.LineEdit | LineEdit]] |||| Handle received control characters used for editing.<br />
|-<br />
| valign="top" | [[TWSocket.LineEnd | LineEnd]] |||| End of line character(s) used ot trigger [[TWSocket.OnDataAvailable | OnDataAvailable]].<br />
|-<br />
| valign="top" | [[TWSocket.LineLength | LineLength]] |||| When using LineMode: the length of the received line.<br />
|-<br />
| valign="top" | [[TWSocket.LineLimit | LineLimit]] |||| Maximum line lenght to receive before triggering [[TWSocket.OnLineLimitExceeded | OnLineLimitExceeded]]. See also [[DOS attac]].<br />
|-<br />
| valign="top" | [[TWSocket.LineMode | LineMode]] |||| Use [[TWSocket.LineEnd | LineEnd]] as end of line marker to trigger [[TWSocket.OnDataAvailable | OnDataAvailable]].<br />
|-<br />
| valign="top" | [[TWSocket.LingerOnOff | LingerOnOff]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LingerTimeout | LingerTimeout]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ListenBacklog | ListenBacklog]] |||| Size of pending connection queue in server mode.<br />
|-<br />
| valign="top" | [[TWSocket.LocalAddr | LocalAddr]] |||| The local address where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.LocalPort | LocalPort]] |||| The local port where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.MultiCast | MultiCast]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MultiCastAddrStr | MultiCastAddrStr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MultiCastIpTTL | MultiCastIpTTL]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MultiThreaded | MultiThreaded]] |||| Set when TWSocket has to use his own message pump.<br />
|-<br />
| valign="top" | [[TWSocket.PeerAddr | PeerAddr]] |||| The remote address where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.PeerPort | PeerPort]] |||| The remote port port where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.Port | Port]] |||| ''Client:'' The port to connect to. ''Server:'' The port to listen on.<br />
|-<br />
| width="90" valign="top" | [[TWSocket.PortNum | PortNum]] |||| Integer value of [[TWSocket.Port | Port]].<br />
|-<br />
| valign="top" | [[TWSocket.Proto | Proto]] |||| The protocol to use, can be '''tcp''' or '''tcp'''.<br />
|-<br />
| valign="top" | [[TWSocket.RcvdCnt | RcvdCnt]] |||| Number of character received in internal buffer when using line mode.<br />
|-<br />
| valign="top" | [[TWSocket.RcvdCount | RcvdCount]] |||| Number of characters in receive buffer but not read yet.<br />
|-<br />
| valign="top" | [[TWSocket.RcvdPtr | RcvdPtr]] |||| Internal rceive buffer pointer used for line mode.<br />
|-<br />
| valign="top" | [[TWSocket.ReadCount | ReadCount]] |||| Total number of bytes received.<br />
|-<br />
| valign="top" | [[TWSocket.ReqVerLow | ReqVerLow]] |||| Low part of winsock version to load.<br />
|-<br />
| valign="top" | [[TWSocket.ReqVerHigh | ReqVerHigh]] |||| High part of winsock version to load.<br />
|-<br />
| valign="top" | [[TWSocket.ReuseAddr | ReuseAddr]] |||| Should the compnent try to reuse an address.<br />
|-<br />
| valign="top" | [[TWSocket.SendFlags | SendFlags]] |||| How to send data.<br />
|-<br />
| valign="top" | [[TWSocket.SocksAuthentication | SocksAuthentication]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksLevel | SocksLevel]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksPassword | SocksPassword]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksPort | SocksPort]] |||| Port number for socks server.<br />
|-<br />
| valign="top" | [[TWSocket.SocksServer | SocksServer]] |||| IP or hostname for socks server.<br />
|-<br />
| valign="top" | [[TWSocket.SocksUsercode | SocksUsercode]] |||| Usercode for socks server authentication.<br />
|-<br />
| valign="top" | [[TWSocket.State | State]] |||| Current state of the socket, mainly used for log or display purposes.<br />
|-<br />
| valign="top" | [[TWSocket.Terminated | Terminated]] |||| To be set to terminate synchronous operation prematurely.<br />
|-<br />
| valign="top" | [[TWSocket.Text | Text]] |||| Equivalent to ReceiveStr and SendStr.<br />
|}<br />
<br />
== Methods ==<br />
<br />
{| <br />
| width="140" valign="top" | [[TWSocket.Abort | Abort]] |||| Quick and dirty way to close the socket.<br />
|-<br />
| valign="top" | [[TWSocket.Accept | Accept]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.CancelDnsLookup | CancelDnsLookup]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Close | Close]] |||| Close the socket gracefull.<br />
|-<br />
| valign="top" | [[TWSocket.CloseDelayed | CloseDelayed]] |||| Close the socket gracefull in a message handler.<br />
|-<br />
| valign="top" | [[TWSocket.Connect | Connect]] |||| Connect to a remote host.<br />
|-<br />
| valign="top" | [[TWSocket.Create | Create]] |||| Dynamcly create the component.<br />
|-<br />
| valign="top" | [[TWSocket.DeleteBufferedData | DeleteBufferedData]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Destroy | Destroy]] |||| Destroy the dynamicly created component.<br />
|-<br />
| valign="top" | [[TWSocket.DnsLookup | DnsLookup]] |||| Perform a DNS lookup of a hostname in background. See also [[TWSocket.OnDNSLookupDone | OnDNSLookupDone]].<br />
|-<br />
| valign="top" | [[TWSocket.Dup | Dup]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Flush | Flush]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetPeerAddr | GetPeerAddr]] |||| Returns the remote address where the socket has been bound. See also [[TWSocket.PeerAddr | PeerAddr]].<br />
|-<br />
| valign="top" | [[TWSocket.GetPeerName | GetPeerName]] |||| Returns the remot hostname where the socket has been bound.<br />
|-<br />
| valign="top" | [[TWSocket.GetPeerPort | GetPeerPort]] |||| Returns the remote port where the socket has been bound. See also [[TWSocket.PeerPort | PeerPort]].<br />
|-<br />
| valign="top" | [[TWSocket.GetSockName | GetSockName]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetXAddr | GetXAddr]] |||| Returns the local interface to where the socket has been bound.<br />
|-<br />
| valign="top" | [[TWSocket.GetXPort | GetXPort]] |||| Returns the local port to where the socket has been bound.<br />
|-<br />
| valign="top" | [[TWSocket.Listen | Listen]] |||| Set the socket in listening state to accept inbound connections.<br />
|-<br />
| valign="top" | [[TWSocket.MessageLoop | MessageLoop]] |||| Pump messages until WM_QUIT is received.<br />
|-<br />
| valign="top" | [[TWSocket.MessagePump | MessagePump]] |||| Trigger [[TWSocket.OnMessagePump | OnMessagePump]] or call [[TWSocket.ProcessMessages | ProcessMessages]].<br />
|-<br />
| valign="top" | [[TWSocket.Pause | Pause]] |||| Stop delivery notification of received TCP data.<br />
|-<br />
| valign="top" | [[TWSocket.PeekData | PeekData]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ProcessMessage | ProcessMessage]] |||| Similar as TApplication.ProcessMessage.<br />
|-<br />
| valign="top" | [[TWSocket.ProcessMessages | ProcessMessages]] |||| Similar as TApplication.ProcessMessages.<br />
|-<br />
| valign="top" | [[TWSocket.PutDataInSendBuffer | PutDataInSendBuffer]] |||| Put data in send buffer without sending it.<br />
|-<br />
| valign="top" | [[TWSocket.PutStringInSendBuffer | PutStringInSendBuffer]] |||| Put string in send buffer without sending it.<br />
|-<br />
| valign="top" | [[TWSocket.Receive | Receive]] |||| Receive data in [[TWSocket.OnDataAvailable | OnDataAvailable]].<br />
|-<br />
| valign="top" | [[TWSocket.ReceiveFrom | ReceiveFrom]] |||| <br />
|-<br />
| valign="top" | [[TWSocket.ReceiveStr | ReceiveStr]] |||| Receive string in [[TWSocket.OnDataAvailable | OnDataAvailable]].<br />
|-<br />
| valign="top" | [[TWSocket.Release | Release]] |||| Destroy the dynamicly created TWSocket in a custom message handler.<br />
|-<br />
| valign="top" | [[TWSocket.Resume | Resume]] |||| Resume delivery notification for received data.<br />
|-<br />
| valign="top" | [[TWSocket.ReverseDnsLookup | ReverseDnsLookup]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Send | Send]] |||| Send data.<br />
|-<br />
| valign="top" | [[TWSocket.SendStr | SendStr]] |||| Send a string.<br />
|-<br />
| valign="top" | [[TWSocket.SendTo | SendTo]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SetLingerOption | SetLingerOption]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Shutdown | Shutdown]] |||| Close the socket gracefull.<br />
|-<br />
| valign="top" | [[TWSocket.TimerClear | TimerClear]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.TimerCmp | TimerCmp]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.TimerIsSet | TimerIsSet]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ThreadAttach | ThreadAttach]] |||| Attach the hidden window to a thread.<br />
|-<br />
| valign="top" | [[TWSocket.ThreadDetach | ThreadDetach]] |||| Detach the hidden window from a thread.<br />
|-<br />
| valign="top" | [[TWSocket.WaitForClose | WaitForClose]] |||| <br />
|}<br />
<br />
== Events ==<br />
<br />
{|<br />
| width="140" valign="top" | [[TWSocket.OnBgException | OnBgException]] |||| Background exception occured.<br />
|-<br />
| valign="top" | [[TWSocket.OnChangeState | OnChangeState]] |||| State of TWSocket has changed.<br />
|-<br />
| valign="top" | [[TWSocket.OnDataAvailable | OnDataAvailable]] |||| Data available in internal receive buffer.<br />
|-<br />
| valign="top" | [[TWSocket.OnDataSent | OnDataSent]] |||| Internal sent buffer is completely delivered to winsock.<br />
|-<br />
| width="90" valign="top" | [[TWSocket.OnDebugDisplay | OnDebugDisplay]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.OnDnsLookupDone | OnDnsLookupDone]] |||| [[TWSocket.DNSLookup | DNSLookup]] has finished.<br />
|-<br />
| valign="top" | [[TWSocket.OnError | OnError]] |||| ''Discouraged'', use exception handling instead.<br />
|-<br />
| valign="top" | [[TWSocket.OnLineLimitExceeded | OnLineLimitExceeded]] |||| Denial of service attack<br />
|-<br />
| valign="top" | [[TWSocket.OnMessagePump | OnMessagePump]] |||| To call your own message pump.<br />
|-<br />
| valign="top" | [[TWSocket.OnSendData | OnSendData]] |||| Winsock send buffer is empty, will be filled again by internal send buffer if still data available to send.<br />
|-<br />
| valign="top" | [[TWSocket.OnSessionAvailable | OnSessionAvailable]] |||| Client connected to this server.<br />
|-<br />
| valign="top" | [[TWSocket.OnSessionClosed | OnSessionClosed]] |||| Socket has closed.<br />
|-<br />
| valign="top" | [[TWSocket.OnSessionConnected | OnSessionConnected]] |||| Session to host etablished.<br />
|-<br />
| valign="top" | [[TWSocket.OnSocksAuthState | OnSocksAuthState]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.OnSocksConnected | OnSocksConnected]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.OnSocksError | OnSocksError]] ||||<br />
|}<br />
<br />
== How to ==<br />
<br />
* [[TWSocket.HowTo.Close | Close a TCP session]]<br />
* [[TWSocket.HowTo.Close | Destroy a dynamicly created TWSocket]]<br />
<br />
{{Components_Footer}}</div>Wilfriedhttp://wiki.overbyte.eu/wiki/index.php?title=TWSocket&diff=1898TWSocket2006-02-26T20:09:19Z<p>Wilfried: /* Methods */</p>
<hr />
<div>[[Main_Page | Main page]] -> [[ICS_Components_Reference | ICS component reference]] -> [[TWSocket]]<br />
== Overview ==<br />
<br />
{|<br />
| '''unit''' |||| WSocket.pas<br />
|-<br />
| '''inheritance''' ||||<br />
|}<br />
<br />
TWSocket component is implementing the TCP protocol described in RFC [http://rfc.net/rfc793.html 793] and and UDP protocol described in RFC [http://rfc.net/rfc768.html 768]. Both protocols are encaptulated by the IP protocol described in RFC [http://rfc.net/rfc791.html 791]. TWSocket is used in almost every other ICS component.<br />
<br />
TWSocket component can be used as client or a server. For its use as TCP server however [[TWSocketServer]] is encouraged because of his advanced features.<br />
<br />
== Properties ==<br />
<br />
{| <br />
| width="140" valign="top" | [[TWSocket.Addr | Addr]] |||| ''Client:'' The host to connect to. ''Server:'' The interface to listen on.<br />
|-<br />
| valign="top" | [[TWSocket.AllSent | AllSent]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.BufSize | BufSize]] |||| Size in bytes for dynamic send buffer cells.<br />
|-<br />
| valign="top" | [[TWSocket.ComponentOptions | ComponentOptions]] |||| Used to modify how the component handle some operations.<br />
|-<br />
| valign="top" | [[TWSocket.DnsResult | DnsResult]] |||| Typically called in [[TWSocket.OnDnsLookupDone | OnDnsLookupDone]]. The IP address of the remote host given as argument to [[TWSocket.DnsLookup | DnsLookup]].<br />
|-<br />
| valign="top" | [[TWSocket.DnsResultList | DnsResultList]] |||| Similar to [[TWSocket.DnsResult | DnsResult]] but a TStringList containing the multiple IP's of the host if appropriate.<br />
|-<br />
| valign="top" | [[TWSocket.Handle | Handle]] |||| Handle for the underlaying hidden window.<br />
|-<br />
| valign="top" | [[TWSocket.HSocket | HSocket]] |||| Winsock handle for underlaying socket.<br />
|-<br />
| valign="top" | [[TWSocket.IcsLogger | IcsLogger]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LastError | LastError]] |||| Save the last error occured during socket operation.<br />
|-<br />
| valign="top" | [[TWSocket.LineEcho | LineEcho]] |||| Echo all received characters back to tramitter.<br />
|-<br />
| valign="top" | [[TWSocket.LineEdit | LineEdit]] |||| Handle received control characters used for editing.<br />
|-<br />
| valign="top" | [[TWSocket.LineEnd | LineEnd]] |||| End of line character(s) used ot trigger [[TWSocket.OnDataAvailable | OnDataAvailable]].<br />
|-<br />
| valign="top" | [[TWSocket.LineLength | LineLength]] |||| When using LineMode: the length of the received line.<br />
|-<br />
| valign="top" | [[TWSocket.LineLimit | LineLimit]] |||| Maximum line lenght to receive before triggering [[TWSocket.OnLineLimitExceeded | OnLineLimitExceeded]]. See also [[DOS attac]].<br />
|-<br />
| valign="top" | [[TWSocket.LineMode | LineMode]] |||| Use [[TWSocket.LineEnd | LineEnd]] as end of line marker to trigger [[TWSocket.OnDataAvailable | OnDataAvailable]].<br />
|-<br />
| valign="top" | [[TWSocket.LingerOnOff | LingerOnOff]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LingerTimeout | LingerTimeout]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ListenBacklog | ListenBacklog]] |||| Size of pending connection queue in server mode.<br />
|-<br />
| valign="top" | [[TWSocket.LocalAddr | LocalAddr]] |||| The local address where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.LocalPort | LocalPort]] |||| The local port where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.MultiCast | MultiCast]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MultiCastAddrStr | MultiCastAddrStr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MultiCastIpTTL | MultiCastIpTTL]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MultiThreaded | MultiThreaded]] |||| Set when TWSocket has to use his own message pump.<br />
|-<br />
| valign="top" | [[TWSocket.PeerAddr | PeerAddr]] |||| The remote address where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.PeerPort | PeerPort]] |||| The remote port port where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.Port | Port]] |||| ''Client:'' The port to connect to. ''Server:'' The port to listen on.<br />
|-<br />
| width="90" valign="top" | [[TWSocket.PortNum | PortNum]] |||| Integer value of [[TWSocket.Port | Port]].<br />
|-<br />
| valign="top" | [[TWSocket.Proto | Proto]] |||| The protocol to use, can be '''tcp''' or '''tcp'''.<br />
|-<br />
| valign="top" | [[TWSocket.RcvdCnt | RcvdCnt]] |||| Number of character received in internal buffer when using line mode.<br />
|-<br />
| valign="top" | [[TWSocket.RcvdCount | RcvdCount]] |||| Number of characters in receive buffer but not read yet.<br />
|-<br />
| valign="top" | [[TWSocket.RcvdPtr | RcvdPtr]] |||| Internal rceive buffer pointer used for line mode.<br />
|-<br />
| valign="top" | [[TWSocket.ReadCount | ReadCount]] |||| Total number of bytes received.<br />
|-<br />
| valign="top" | [[TWSocket.ReqVerLow | ReqVerLow]] |||| Low part of winsock version to load.<br />
|-<br />
| valign="top" | [[TWSocket.ReqVerHigh | ReqVerHigh]] |||| High part of winsock version to load.<br />
|-<br />
| valign="top" | [[TWSocket.ReuseAddr | ReuseAddr]] |||| Should the compnent try to reuse an address.<br />
|-<br />
| valign="top" | [[TWSocket.SendFlags | SendFlags]] |||| How to send data.<br />
|-<br />
| valign="top" | [[TWSocket.SocksAuthentication | SocksAuthentication]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksLevel | SocksLevel]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksPassword | SocksPassword]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksPort | SocksPort]] |||| Port number for socks server.<br />
|-<br />
| valign="top" | [[TWSocket.SocksServer | SocksServer]] |||| IP or hostname for socks server.<br />
|-<br />
| valign="top" | [[TWSocket.SocksUsercode | SocksUsercode]] |||| Usercode for socks server authentication.<br />
|-<br />
| valign="top" | [[TWSocket.State | State]] |||| Current state of the socket, mainly used for log or display purposes.<br />
|-<br />
| valign="top" | [[TWSocket.Terminated | Terminated]] |||| To be set to terminate synchronous operation prematurely.<br />
|-<br />
| valign="top" | [[TWSocket.Text | Text]] |||| Equivalent to ReceiveStr and SendStr.<br />
|}<br />
<br />
== Methods ==<br />
<br />
{| <br />
| width="140" valign="top" | [[TWSocket.Abort | Abort]] |||| Quick and dirty way to close the socket.<br />
|-<br />
| valign="top" | [[TWSocket.Accept | Accept]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.CancelDnsLookup | CancelDnsLookup]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Close | Close]] |||| Close the socket gracefull.<br />
|-<br />
| valign="top" | [[TWSocket.CloseDelayed | CloseDelayed]] |||| Close the socket gracefull in a message handler.<br />
|-<br />
| valign="top" | [[TWSocket.Connect | Connect]] |||| Connect to a remote host.<br />
|-<br />
| valign="top" | [[TWSocket.Create | Create]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.DeleteBufferedData | DeleteBufferedData]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Destroy | Destroy]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.DnsLookup | DnsLookup]] |||| Perform a DNS lookup of a hostname in background. See also [[TWSocket.OnDNSLookupDone | OnDNSLookupDone]].<br />
|-<br />
| valign="top" | [[TWSocket.Dup | Dup]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Flush | Flush]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetPeerAddr | GetPeerAddr]] |||| Returns the remote address where the socket has been bound. See also [[TWSocket.PeerAddr]].<br />
|-<br />
| valign="top" | [[TWSocket.GetPeerName | GetPeerName]] |||| Returns the remot hostname where the socket has been bound.<br />
|-<br />
| valign="top" | [[TWSocket.GetPeerPort | GetPeerPort]] |||| Returns the remote port where the socket has been bound. See also [[TWSocket.PeerPort]].<br />
|-<br />
| valign="top" | [[TWSocket.GetSockName | GetSockName]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetXAddr | GetXAddr]] |||| Returns the local interface to where the socket has been bound.<br />
|-<br />
| valign="top" | [[TWSocket.GetXPort | GetXPort]] |||| Returns the local port to where the socket has been bound.<br />
|-<br />
| valign="top" | [[TWSocket.Listen | Listen]] |||| Set the socket in listening state to accept inbound connections.<br />
|-<br />
| valign="top" | [[TWSocket.MessageLoop | MessageLoop]] |||| Pump messages until WM_QUIT is received.<br />
|-<br />
| valign="top" | [[TWSocket.MessagePump | MessagePump]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Pause | Pause]] |||| Stop delivery notification of received TCP data.<br />
|-<br />
| valign="top" | [[TWSocket.PeekData | PeekData]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ProcessMessage | ProcessMessage]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ProcessMessages | ProcessMessages]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.PutDataInSendBuffer | PutDataInSendBuffer]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.PutStringInSendBuffer | PutStringInSendBuffer]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Receive | Receive]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReceiveFrom | ReceiveFrom]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReceiveStr | ReceiveStr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Release | Release]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Resume | Resume]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReverseDnsLookup | ReverseDnsLookup]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Send | Send]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SendStr | SendStr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SendTo | SendTo]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SetLingerOption | SetLingerOption]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Shutdown | Shutdown]] |||| Close the socket gracefull.<br />
|-<br />
| valign="top" | [[TWSocket.TimerClear | TimerClear]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.TimerCmp | TimerCmp]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.TimerIsSet | TimerIsSet]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ThreadAttach | ThreadAttach]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ThreadDetach | ThreadDetach]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.WaitForClose | WaitForClose]] |||| Align test<br />
|}<br />
<br />
== Events ==<br />
<br />
{|<br />
| width="140" valign="top" | [[TWSocket.OnBgException | OnBgException]] |||| Background exception occured.<br />
|-<br />
| valign="top" | [[TWSocket.OnChangeState | OnChangeState]] |||| State of TWSocket has changed.<br />
|-<br />
| valign="top" | [[TWSocket.OnDataAvailable | OnDataAvailable]] |||| Data available in internal receive buffer.<br />
|-<br />
| valign="top" | [[TWSocket.OnDataSent | OnDataSent]] |||| Internal sent buffer is completely delivered to winsock.<br />
|-<br />
| width="90" valign="top" | [[TWSocket.OnDebugDisplay | OnDebugDisplay]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.OnDnsLookupDone | OnDnsLookupDone]] |||| [[TWSocket.DNSLookup | DNSLookup]] has finished.<br />
|-<br />
| valign="top" | [[TWSocket.OnError | OnError]] |||| ''Discouraged'', use exception handling instead.<br />
|-<br />
| valign="top" | [[TWSocket.OnLineLimitExceeded | OnLineLimitExceeded]] |||| Denial of service attack<br />
|-<br />
| valign="top" | [[TWSocket.OnMessagePump | OnMessagePump]] |||| To call your own message pump.<br />
|-<br />
| valign="top" | [[TWSocket.OnSendData | OnSendData]] |||| Winsock send buffer is empty, will be filled again by internal send buffer if still data available to send.<br />
|-<br />
| valign="top" | [[TWSocket.OnSessionAvailable | OnSessionAvailable]] |||| Client connected to this server.<br />
|-<br />
| valign="top" | [[TWSocket.OnSessionClosed | OnSessionClosed]] |||| Socket has closed.<br />
|-<br />
| valign="top" | [[TWSocket.OnSessionConnected | OnSessionConnected]] |||| Session to host etablished.<br />
|-<br />
| valign="top" | [[TWSocket.OnSocksAuthState | OnSocksAuthState]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.OnSocksConnected | OnSocksConnected]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.OnSocksError | OnSocksError]] ||||<br />
|}<br />
<br />
== How to ==<br />
<br />
* [[TWSocket.HowTo.Close | Close a TCP session]]<br />
* [[TWSocket.HowTo.Close | Destroy a dynamicly created TWSocket]]<br />
<br />
{{Components_Footer}}</div>Wilfriedhttp://wiki.overbyte.eu/wiki/index.php?title=Asynchronous_Paradigm&diff=1894Asynchronous Paradigm2006-02-26T10:37:25Z<p>Wilfried: /* Blocking vs. Non-Blocking */</p>
<hr />
<div>To Block or not to Block<br />
<br />
==Non-Blocking==<br />
<br />
Think of windows programming. It's event driven. Your application doesn't wait in a loop polling the status of a button until it is pressed, instead it gets notified about a button click, in other words an event is triggered. You simply place code to be executed in the event handler.<br />
When the user hits the button event OnClick is fired and your code is run. Very efficient, this is called event-driven or non-blocking or asynchronous (async).<br />
<br />
When you call an asynchronous method it will return immediately, regardless whether it has finished or not, an event handler will be called later when the method has finished. This also means that your application is capable to do something else in the meanwhile so the following pseudo code suitable for blocking internet components would NOT work with non-blocking ICS components:<br />
<br />
Connect<br />
Send(Something) <br />
<br />
Because Connect would return immediately without even making sure it has finished successfully and next line would be executed at once. Thus Send(Something) would the fail because it's trying to send data even though there is no connection established to the server yet.<br />
<br />
<br />
So you need to design your program a bit different. Just like OnClick, the ICS components provide many events allowing you to control program flow. After the event handler has been assigned you have to call the method, from then on you rely on events. So you just call Connect, that's it:<br />
<br />
'''procedure''' TForm1.MySendData;<br />
'''begin ''' <br />
WSocket1.OnSessionConnected := WSocket1SessionConnected;<br />
WSocket1.Connect<br />
'''end''';<br />
<br />
Later when method Connect has finished event OnSessionConnected will fire. From within its event handler you can safely send data.<br />
<br />
'''procedure''' TForm1.WSocket1SessionConnected(Sender: TObject; ErrCode: Word);<br />
'''begin'''<br />
WSocket1.Send(Something) <br />
'''end''';<br />
<br />
Very easy, isn't it?<br />
<br />
The same principle applies when data is received. You never request to read data, you never wait until data is received completely, but simply assign the appropriate event handler to event OnDataAvailable and your program gets notified as long as data is available. <br />
<br />
'''procedure''' TForm1.WSocket1DataAvailable(Sender: TObject; ErrCode: Word);<br />
'''var'''<br />
S : '''String'''; <br />
'''begin'''<br />
'''if''' ErrCode = 0 '''then''' '''begin'''<br />
S := WSocket1.ReceiveStr;<br />
'''if''' S = <font color="Navy">'Hello'#13#10</font> '''then'''<br />
SendStr(<font color="Navy">'Hi there'#13#10</font>);<br />
'''end'''; <br />
'''end''';<br />
<br />
Note that OnDataAvailable will fire again if you do not receive all pending data in one go.<br />
<br />
==Blocking==<br />
<br />
Blocking or synchronous (sync) methods do NOT return until they have finished, so our first sample would work: <br />
<br />
Connect<br />
Send(Something) <br />
<br />
Connect won't return until the connection to the server has been established or an error occured. While the program tries to connect it cannot do anything else, it blocks execution even though method connect may just sit there waiting for a server response. Blocking calls may even freeze the GUI unless you use multiple threads. <br />
'''''ICS provides asynchronous as well as synchronous methods and components''''' for most upper protocol implementations. Note that '''''ICS does not freeze your GUI''''' because even in synchronous mode window messages are being processed.<br />
<br />
==Blocking vs. Non-Blocking==<br />
<br />
Due to the non-blocking nature of ICS it is very easy to handle hundreds of concurrent connections within a single thread.<br />
<br />
I give you a pseudo example:<br />
<br />
'''procedure''' TForm1.MySendData;<br />
'''var'''<br />
I : Integer; <br />
'''begin ''' <br />
'''for''' I := 0 '''to''' List.Count -1 '''do'''<br />
TWSocket(List[I]).Connect;<br />
'''end''';<br />
<br />
'''procedure''' TForm1.WSocket1SessionConnect(Sender: TObject; ErrCode: Word);<br />
'''begin'''<br />
'''if''' ErrCode = 0 '''then'''<br />
TWSocket(Sender).Send(Something) <br />
'''end'''; <br />
<br />
<br />
With blocking components multiple concurrent connections are only possible if each connection is executed in its own thread context. But threads must be created, freed, synchronized or managed by so called thread pools, this all doesn't speed up things as you can imagine.</div>Wilfriedhttp://wiki.overbyte.eu/wiki/index.php?title=Asynchronous_Paradigm&diff=1893Asynchronous Paradigm2006-02-26T10:35:53Z<p>Wilfried: /* Non-Blocking */</p>
<hr />
<div>To Block or not to Block<br />
<br />
==Non-Blocking==<br />
<br />
Think of windows programming. It's event driven. Your application doesn't wait in a loop polling the status of a button until it is pressed, instead it gets notified about a button click, in other words an event is triggered. You simply place code to be executed in the event handler.<br />
When the user hits the button event OnClick is fired and your code is run. Very efficient, this is called event-driven or non-blocking or asynchronous (async).<br />
<br />
When you call an asynchronous method it will return immediately, regardless whether it has finished or not, an event handler will be called later when the method has finished. This also means that your application is capable to do something else in the meanwhile so the following pseudo code suitable for blocking internet components would NOT work with non-blocking ICS components:<br />
<br />
Connect<br />
Send(Something) <br />
<br />
Because Connect would return immediately without even making sure it has finished successfully and next line would be executed at once. Thus Send(Something) would the fail because it's trying to send data even though there is no connection established to the server yet.<br />
<br />
<br />
So you need to design your program a bit different. Just like OnClick, the ICS components provide many events allowing you to control program flow. After the event handler has been assigned you have to call the method, from then on you rely on events. So you just call Connect, that's it:<br />
<br />
'''procedure''' TForm1.MySendData;<br />
'''begin ''' <br />
WSocket1.OnSessionConnected := WSocket1SessionConnected;<br />
WSocket1.Connect<br />
'''end''';<br />
<br />
Later when method Connect has finished event OnSessionConnected will fire. From within its event handler you can safely send data.<br />
<br />
'''procedure''' TForm1.WSocket1SessionConnected(Sender: TObject; ErrCode: Word);<br />
'''begin'''<br />
WSocket1.Send(Something) <br />
'''end''';<br />
<br />
Very easy, isn't it?<br />
<br />
The same principle applies when data is received. You never request to read data, you never wait until data is received completely, but simply assign the appropriate event handler to event OnDataAvailable and your program gets notified as long as data is available. <br />
<br />
'''procedure''' TForm1.WSocket1DataAvailable(Sender: TObject; ErrCode: Word);<br />
'''var'''<br />
S : '''String'''; <br />
'''begin'''<br />
'''if''' ErrCode = 0 '''then''' '''begin'''<br />
S := WSocket1.ReceiveStr;<br />
'''if''' S = <font color="Navy">'Hello'#13#10</font> '''then'''<br />
SendStr(<font color="Navy">'Hi there'#13#10</font>);<br />
'''end'''; <br />
'''end''';<br />
<br />
Note that OnDataAvailable will fire again if you do not receive all pending data in one go.<br />
<br />
==Blocking==<br />
<br />
Blocking or synchronous (sync) methods do NOT return until they have finished, so our first sample would work: <br />
<br />
Connect<br />
Send(Something) <br />
<br />
Connect won't return until the connection to the server has been established or an error occured. While the program tries to connect it cannot do anything else, it blocks execution even though method connect may just sit there waiting for a server response. Blocking calls may even freeze the GUI unless you use multiple threads. <br />
'''''ICS provides asynchronous as well as synchronous methods and components''''' for most upper protocol implementations. Note that '''''ICS does not freeze your GUI''''' because even in synchronous mode window messages are being processed.<br />
<br />
==Blocking vs. Non-Blocking==<br />
<br />
Due to the non-blocking nature of ICS it is very easy to handle hundreds of concurrent connections within a single thread.<br />
<br />
I give you a pseudo example:<br />
<br />
procedure TForm1.MySendData;<br />
var<br />
I : Integer; <br />
begin <br />
for I := 0 to List.Count -1 do<br />
TWSocket(List[I]).Connect;<br />
end;<br />
<br />
procedure TForm1.WSocket1SessionConnect(Sender: TObject; ErrCode: Word);<br />
begin<br />
if ErrCode = 0 then<br />
TWSocket(Sender).Send(Something) <br />
end; <br />
<br />
<br />
With blocking components multiple concurrent connections are only possible if each connection is executed in its own thread context. But threads must be created, freed, synchronized or managed by so called thread pools, this all doesn't speed up things as you can imagine.</div>Wilfriedhttp://wiki.overbyte.eu/wiki/index.php?title=Sending_and_receiving_data&diff=1892Sending and receiving data2006-02-26T10:02:31Z<p>Wilfried: /* Mixed mode */</p>
<hr />
<div>[[Main_Page | Main page]] -> [[FAQ]] -> [[Sending and receiving data]]<br />
<br />
== General ==<br />
<br />
There are several ways to transfer data. No matter if it is a file, an image, textual or raw data, it is all the same. What is needed is a common language between the data sender and the data receiver, in order for each to understand the other. This language defines a format. Formatting data is a way to "shape" it, describing its beginning and its end, in order for the receiver to know where data starts and ends.<br />
<br />
<!--<br />
We use the term ''binary data'' not to make a difference to ''ASCII'' or human readable data, but for data that has an unpredictable content, meaning we cannot use line mode just like that because whatever combination of characters you choose it ''could'' be in the data stream itself.<br />
<br />
== Solutions ==<br />
--><br />
<br />
Many formats are of course possible, mainly depending upon the kind of data itself. Basically, we can consider that we have two kinds of data :<br />
* predictable data content<br />
* unpredictable data content<br />
<br />
In the first case, we know what kind of content the data contains - ie the byte set that can be used is known (byte values from 32 to 127, for example). In the other case, the data content is not known - ie the byte set can be any possible byte value (from 0 to 255). This major difference will mostly determine the format of the data to be exchanged, defining then the protocol.<br />
<br />
Concerning Predictable Data Content, as the content values are known by advance - a subset of the 256 possible byte values, it is possible to know which byte values '''cannot''' be part of the data. This hint let us the possibility to create a delimiter made of one or more of these "extra data" byte values. This delimiter, sent after data, may then help us to know where data ends. This mode where a delimiter is placed at the end of data is named LineMode.<br />
<br />
Concerning Unpredictable Data Content, as the content values are never known by advance - byte set values starts at 0 and ends at 255, if we plan to send several data packet (for example several records) at once, then we have to tell the receiver the size of the data we're going to send for each packet. This mode to "format" data packet by prefixing it with its size is call PacketMode.<br />
<br />
And if we plan to send at the same time some Predictable Data Content and some Unpredictable Data Content, we can then imagine a combination of both mode.<br />
<br />
[[TWSocket]] has the ability to help you in implementing such a protocol. It is able to manage data using [[TWSocket.LineMode | LineMode]] and PacketMode (which is Non-LineMode).<br />
<br />
== Line mode ==<br />
<br />
Line mode is the most widely used, specially with ''ascii'' based protocols. But there are many protocols where line mode is used with unpredictable data. In that case that data has to converted into a specific range of bytes. The most used encoding mechanism are described here.<br />
<br />
=== Base-64 ===<br />
<br />
''Base64'' is an encoding process using a 64 letter alphabet where each letter representing 6 bits in the input stream. It is described in RFC [http://rfc.net/rfc2045.html#p24 2045]. All encoding and decoding procedures can be found in unit MimeUtil. The encoded data is about 33 percent larger and not human readable. Every character not used in the Base64 alphabet can be used as control character, including line end.<br />
<br />
=== ASCII-hex ===<br />
<br />
''ASCII-hex'' is used in many protocols. Every character is converted into his hexadecimal equivalent and sent as such. For example the string '123' is sent as '313233'. The encoded data is twice as long and difficult human readable. Every character except 0..9, A..F can be used as control character, including line end.<br />
<br />
=== Escaping ===<br />
<br />
Escaping is very often used. Control characters including line end has to be chosen in a way they are as less as possible in the original data. The principle is to precede the control characters with an escape character and replace them by other characters. Very often a NULL character is escaped as well. Most of the time the encoded data is only a little longer than original and good human readable.<br />
<br />
=== Quoted-Printable ===<br />
<br />
The Quoted-Printable encoding as specified in RFC [http://RFC.net/rfc1521.html#p18 1521] is intended to represent data which is largely human readable. It encodes certain byte ranges into their hexadecimal presentation. The encoded data remains good human readable. Procedures to encode and decode Quoted-Printable can be found in unit MimeUtil.<br />
<br />
<!--<br />
The Quoted-Printable encoding as specified in RFC [http://RFC.net/rfc1521.html#p18 1521] is intended to represent data that largely consists of bytes that correspond to printable characters in the ASCII character set. It encodes the data in such a way that the resulting bytes are unlikely to be modified by mail transport. If the data being encoded are mostly ASCII text, the encoded form of the data remains largely recognizable by humans. Procedures to encode and decode Quoted-Printable can be found in unit MimeUtil.<br />
--><br />
<br />
== Packet mode ==<br />
<br />
Packet mode is also very widely used and most of the time designed for a specific protocol. In packet mode the data has a specific structure which eventually can be different depending on the type of packet even within the same protocol. The most universal ones are explained here.<br />
<br />
=== Header ===<br />
<br />
A very often used technique is to precede the data with a header. Presides other control information this header has a field containing the length of the data.<br />
<br />
The length field is 1, 2 or 4 bytes long. Note that it is common habitude in communications to represent numbers in [[Endian | Big Endian]] format while Intel CPU use by design [[Endian | Little Endian]] format.<br />
<br />
Less used but also a very good technique is to represent the length field in hexadecimal format of 2, 4 or 8 bytes. Advantage is that it is human readable.<br />
<br />
=== Fixed length data ===<br />
<br />
Fixed length data is where all packets of the same type have the same structure and length. Mostly the type of the structure is indicated in a field somewhere at the beginning. If such a structure contains a data field of variable length then eater the data is padded or its length is indicated in a field in the structure.<br />
<br />
== Mixed mode ==<br />
<br />
[[TWSocket]] has the ability to implement a mixed mode protocol by switching [[TWSocket.LineMode | LineMode]] during negotiation.<br />
<br />
=== Example ===<br />
<br />
* ''A'' want to send data, so he tell it to ''B'' during negotiation, with ''ascii'' commands using [[TWSocket.LineMode | LineMode]], including the size.<br />
* After receiving that information, ''B'' switch [[TWSocket.LineMode | LineMode]] off then tell it to ''A''.<br />
* When ''A'' receive this confirmation it start sending exact what has negotiated.<br />
* When ''B'' has received it all, then he switch [[TWSocket.LineMode | LineMode]] back on then tell it to ''A''.<br />
* After receiving that information both are again in negotiation phase.<br />
<br />
== Conclusion ==<br />
<br />
Difficult to explain something :)<br />
<br />
<br />
[[User:Wilfried|Wilfried]] 20:18, 21 February 2006 (CET)</div>Wilfriedhttp://wiki.overbyte.eu/wiki/index.php?title=Sending_and_receiving_data&diff=1891Sending and receiving data2006-02-26T09:31:29Z<p>Wilfried: /* Packet mode */</p>
<hr />
<div>[[Main_Page | Main page]] -> [[FAQ]] -> [[Sending and receiving data]]<br />
<br />
== General ==<br />
<br />
There are several ways to transfer data. No matter if it is a file, an image, textual or raw data, it is all the same. What is needed is a common language between the data sender and the data receiver, in order for each to understand the other. This language defines a format. Formatting data is a way to "shape" it, describing its beginning and its end, in order for the receiver to know where data starts and ends.<br />
<br />
<!--<br />
We use the term ''binary data'' not to make a difference to ''ASCII'' or human readable data, but for data that has an unpredictable content, meaning we cannot use line mode just like that because whatever combination of characters you choose it ''could'' be in the data stream itself.<br />
<br />
== Solutions ==<br />
--><br />
<br />
Many formats are of course possible, mainly depending upon the kind of data itself. Basically, we can consider that we have two kinds of data :<br />
* predictable data content<br />
* unpredictable data content<br />
<br />
In the first case, we know what kind of content the data contains - ie the byte set that can be used is known (byte values from 32 to 127, for example). In the other case, the data content is not known - ie the byte set can be any possible byte value (from 0 to 255). This major difference will mostly determine the format of the data to be exchanged, defining then the protocol.<br />
<br />
Concerning Predictable Data Content, as the content values are known by advance - a subset of the 256 possible byte values, it is possible to know which byte values '''cannot''' be part of the data. This hint let us the possibility to create a delimiter made of one or more of these "extra data" byte values. This delimiter, sent after data, may then help us to know where data ends. This mode where a delimiter is placed at the end of data is named LineMode.<br />
<br />
Concerning Unpredictable Data Content, as the content values are never known by advance - byte set values starts at 0 and ends at 255, if we plan to send several data packet (for example several records) at once, then we have to tell the receiver the size of the data we're going to send for each packet. This mode to "format" data packet by prefixing it with its size is call PacketMode.<br />
<br />
And if we plan to send at the same time some Predictable Data Content and some Unpredictable Data Content, we can then imagine a combination of both mode.<br />
<br />
[[TWSocket]] has the ability to help you in implementing such a protocol. It is able to manage data using [[TWSocket.LineMode | LineMode]] and PacketMode (which is Non-LineMode).<br />
<br />
== Line mode ==<br />
<br />
Line mode is the most widely used, specially with ''ascii'' based protocols. But there are many protocols where line mode is used with unpredictable data. In that case that data has to converted into a specific range of bytes. The most used encoding mechanism are described here.<br />
<br />
=== Base-64 ===<br />
<br />
''Base64'' is an encoding process using a 64 letter alphabet where each letter representing 6 bits in the input stream. It is described in RFC [http://rfc.net/rfc2045.html#p24 2045]. All encoding and decoding procedures can be found in unit MimeUtil. The encoded data is about 33 percent larger and not human readable. Every character not used in the Base64 alphabet can be used as control character, including line end.<br />
<br />
=== ASCII-hex ===<br />
<br />
''ASCII-hex'' is used in many protocols. Every character is converted into his hexadecimal equivalent and sent as such. For example the string '123' is sent as '313233'. The encoded data is twice as long and difficult human readable. Every character except 0..9, A..F can be used as control character, including line end.<br />
<br />
=== Escaping ===<br />
<br />
Escaping is very often used. Control characters including line end has to be chosen in a way they are as less as possible in the original data. The principle is to precede the control characters with an escape character and replace them by other characters. Very often a NULL character is escaped as well. Most of the time the encoded data is only a little longer than original and good human readable.<br />
<br />
=== Quoted-Printable ===<br />
<br />
The Quoted-Printable encoding as specified in RFC [http://RFC.net/rfc1521.html#p18 1521] is intended to represent data which is largely human readable. It encodes certain byte ranges into their hexadecimal presentation. The encoded data remains good human readable. Procedures to encode and decode Quoted-Printable can be found in unit MimeUtil.<br />
<br />
<!--<br />
The Quoted-Printable encoding as specified in RFC [http://RFC.net/rfc1521.html#p18 1521] is intended to represent data that largely consists of bytes that correspond to printable characters in the ASCII character set. It encodes the data in such a way that the resulting bytes are unlikely to be modified by mail transport. If the data being encoded are mostly ASCII text, the encoded form of the data remains largely recognizable by humans. Procedures to encode and decode Quoted-Printable can be found in unit MimeUtil.<br />
--><br />
<br />
== Packet mode ==<br />
<br />
Packet mode is also very widely used and most of the time designed for a specific protocol. In packet mode the data has a specific structure which eventually can be different depending on the type of packet even within the same protocol. The most universal ones are explained here.<br />
<br />
=== Header ===<br />
<br />
A very often used technique is to precede the data with a header. Presides other control information this header has a field containing the length of the data.<br />
<br />
The length field is 1, 2 or 4 bytes long. Note that it is common habitude in communications to represent numbers in [[Endian | Big Endian]] format while Intel CPU use by design [[Endian | Little Endian]] format.<br />
<br />
Less used but also a very good technique is to represent the length field in hexadecimal format of 2, 4 or 8 bytes. Advantage is that it is human readable.<br />
<br />
=== Fixed length data ===<br />
<br />
Fixed length data is where all packets of the same type have the same structure and length. Mostly the type of the structure is indicated in a field somewhere at the beginning. If such a structure contains a data field of variable length then eater the data is padded or its length is indicated in a field in the structure.<br />
<br />
== Mixed mode ==<br />
<br />
== Conclusion ==<br />
<br />
Difficult to explain something :)<br />
<br />
<br />
[[User:Wilfried|Wilfried]] 20:18, 21 February 2006 (CET)</div>Wilfriedhttp://wiki.overbyte.eu/wiki/index.php?title=Sending_and_receiving_data&diff=1890Sending and receiving data2006-02-26T08:37:10Z<p>Wilfried: /* Line mode */</p>
<hr />
<div>[[Main_Page | Main page]] -> [[FAQ]] -> [[Sending and receiving data]]<br />
<br />
== General ==<br />
<br />
There are several ways to transfer data. No matter if it is a file, an image, textual or raw data, it is all the same. What is needed is a common language between the data sender and the data receiver, in order for each to understand the other. This language defines a format. Formatting data is a way to "shape" it, describing its beginning and its end, in order for the receiver to know where data starts and ends.<br />
<br />
<!--<br />
We use the term ''binary data'' not to make a difference to ''ASCII'' or human readable data, but for data that has an unpredictable content, meaning we cannot use line mode just like that because whatever combination of characters you choose it ''could'' be in the data stream itself.<br />
<br />
== Solutions ==<br />
--><br />
<br />
Many formats are of course possible, mainly depending upon the kind of data itself. Basically, we can consider that we have two kinds of data :<br />
* predictable data content<br />
* unpredictable data content<br />
<br />
In the first case, we know what kind of content the data contains - ie the byte set that can be used is known (byte values from 32 to 127, for example). In the other case, the data content is not known - ie the byte set can be any possible byte value (from 0 to 255). This major difference will mostly determine the format of the data to be exchanged, defining then the protocol.<br />
<br />
Concerning Predictable Data Content, as the content values are known by advance - a subset of the 256 possible byte values, it is possible to know which byte values '''cannot''' be part of the data. This hint let us the possibility to create a delimiter made of one or more of these "extra data" byte values. This delimiter, sent after data, may then help us to know where data ends. This mode where a delimiter is placed at the end of data is named LineMode.<br />
<br />
Concerning Unpredictable Data Content, as the content values are never known by advance - byte set values starts at 0 and ends at 255, if we plan to send several data packet (for example several records) at once, then we have to tell the receiver the size of the data we're going to send for each packet. This mode to "format" data packet by prefixing it with its size is call PacketMode.<br />
<br />
And if we plan to send at the same time some Predictable Data Content and some Unpredictable Data Content, we can then imagine a combination of both mode.<br />
<br />
[[TWSocket]] has the ability to help you in implementing such a protocol. It is able to manage data using [[TWSocket.LineMode | LineMode]] and PacketMode (which is Non-LineMode).<br />
<br />
== Line mode ==<br />
<br />
Line mode is the most widely used, specially with ''ascii'' based protocols. But there are many protocols where line mode is used with unpredictable data. In that case that data has to converted into a specific range of bytes. The most used encoding mechanism are described here.<br />
<br />
=== Base-64 ===<br />
<br />
''Base64'' is an encoding process using a 64 letter alphabet where each letter representing 6 bits in the input stream. It is described in RFC [http://rfc.net/rfc2045.html#p24 2045]. All encoding and decoding procedures can be found in unit MimeUtil. The encoded data is about 33 percent larger and not human readable. Every character not used in the Base64 alphabet can be used as control character, including line end.<br />
<br />
=== ASCII-hex ===<br />
<br />
''ASCII-hex'' is used in many protocols. Every character is converted into his hexadecimal equivalent and sent as such. For example the string '123' is sent as '313233'. The encoded data is twice as long and difficult human readable. Every character except 0..9, A..F can be used as control character, including line end.<br />
<br />
=== Escaping ===<br />
<br />
Escaping is very often used. Control characters including line end has to be chosen in a way they are as less as possible in the original data. The principle is to precede the control characters with an escape character and replace them by other characters. Very often a NULL character is escaped as well. Most of the time the encoded data is only a little longer than original and good human readable.<br />
<br />
=== Quoted-Printable ===<br />
<br />
The Quoted-Printable encoding as specified in RFC [http://RFC.net/rfc1521.html#p18 1521] is intended to represent data which is largely human readable. It encodes certain byte ranges into their hexadecimal presentation. The encoded data remains good human readable. Procedures to encode and decode Quoted-Printable can be found in unit MimeUtil.<br />
<br />
<!--<br />
The Quoted-Printable encoding as specified in RFC [http://RFC.net/rfc1521.html#p18 1521] is intended to represent data that largely consists of bytes that correspond to printable characters in the ASCII character set. It encodes the data in such a way that the resulting bytes are unlikely to be modified by mail transport. If the data being encoded are mostly ASCII text, the encoded form of the data remains largely recognizable by humans. Procedures to encode and decode Quoted-Printable can be found in unit MimeUtil.<br />
--><br />
<br />
== Packet mode ==<br />
<br />
=== Preceding each data packet with his length ===<br />
<br />
This is a very common used technique. The first 1, 2 o 4 bytes of the data represent the length of the packet. Note that it is common habitude in communications to represent the length header in [[Endian | Big Endian]] format while Intel CPU use by design [[Endian | Little Endian]] format.<br />
<br />
Less used but also a good technique is to represent the preceding length in hex format of 2, 4 or 8 bytes. Advantage is that this part of the header is human readable.<br />
<br />
=== Fixed length data ===<br />
<br />
== Mixed mode ==<br />
<br />
== Conclusion ==<br />
<br />
Difficult to explain something :)<br />
<br />
<br />
[[User:Wilfried|Wilfried]] 20:18, 21 February 2006 (CET)</div>Wilfriedhttp://wiki.overbyte.eu/wiki/index.php?title=Sending_and_receiving_data&diff=1889Sending and receiving data2006-02-26T08:35:53Z<p>Wilfried: /* Line mode */</p>
<hr />
<div>[[Main_Page | Main page]] -> [[FAQ]] -> [[Sending and receiving data]]<br />
<br />
== General ==<br />
<br />
There are several ways to transfer data. No matter if it is a file, an image, textual or raw data, it is all the same. What is needed is a common language between the data sender and the data receiver, in order for each to understand the other. This language defines a format. Formatting data is a way to "shape" it, describing its beginning and its end, in order for the receiver to know where data starts and ends.<br />
<br />
<!--<br />
We use the term ''binary data'' not to make a difference to ''ASCII'' or human readable data, but for data that has an unpredictable content, meaning we cannot use line mode just like that because whatever combination of characters you choose it ''could'' be in the data stream itself.<br />
<br />
== Solutions ==<br />
--><br />
<br />
Many formats are of course possible, mainly depending upon the kind of data itself. Basically, we can consider that we have two kinds of data :<br />
* predictable data content<br />
* unpredictable data content<br />
<br />
In the first case, we know what kind of content the data contains - ie the byte set that can be used is known (byte values from 32 to 127, for example). In the other case, the data content is not known - ie the byte set can be any possible byte value (from 0 to 255). This major difference will mostly determine the format of the data to be exchanged, defining then the protocol.<br />
<br />
Concerning Predictable Data Content, as the content values are known by advance - a subset of the 256 possible byte values, it is possible to know which byte values '''cannot''' be part of the data. This hint let us the possibility to create a delimiter made of one or more of these "extra data" byte values. This delimiter, sent after data, may then help us to know where data ends. This mode where a delimiter is placed at the end of data is named LineMode.<br />
<br />
Concerning Unpredictable Data Content, as the content values are never known by advance - byte set values starts at 0 and ends at 255, if we plan to send several data packet (for example several records) at once, then we have to tell the receiver the size of the data we're going to send for each packet. This mode to "format" data packet by prefixing it with its size is call PacketMode.<br />
<br />
And if we plan to send at the same time some Predictable Data Content and some Unpredictable Data Content, we can then imagine a combination of both mode.<br />
<br />
[[TWSocket]] has the ability to help you in implementing such a protocol. It is able to manage data using [[TWSocket.LineMode | LineMode]] and PacketMode (which is Non-LineMode).<br />
<br />
== Line mode ==<br />
<br />
Line mode is the most widely used, specially with ''ascii'' based protocols. But there are many protocols where line mode is used with unpredictable data. In that case that data has to converted into a specific range of bytes. The most used encoding mechanism are described here.<br />
<br />
=== Base-64 ===<br />
<br />
''Base64'' is an encoding process using a 64 letter alphabet where each letter representing 6 bits in the input stream. It is described in RFC [http://rfc.net/rfc2045.html#p24 2045]. All encoding and decoding procedures can be found in unit MimeUtil. The encoded data is about 33 percent larger and not human readable. Every character not used in the Base64 alphabet can be used as control character, including line end.<br />
<br />
=== ASCII-hex ===<br />
<br />
''ASCII-hex'' is used in many protocols. Every character is converted into his hexadecimal equivalent and sent as such. For example the string '123' is sent as '313233'. The encoded data is twice as long and difficult human readable. Every character except 0..9, A..F can be used as control character, including line end.<br />
<br />
=== Escaping ===<br />
<br />
Escaping is very often used. Control characters including line end has to be chosen in a way they are as less as possible in the original data. The principle is to precede the control characters with an escape character and replace them by other characters. Very often a NULL character is escaped as well. Most of the time the encoded data is only a little longer than original and good human readable.<br />
<br />
=== Quoted-Printable ===<br />
<br />
The Quoted-Printable encoding as specified in RFC [http://RFC.net/rfc1521.html#p18 1521] is intended to represent data which is largely human readable. It encodes certain byte ranges into their hexadecimal presentation. The encoded data remains good human readable. Procedures to encode and decode Quoted-Printable can be found in unit MimeUtil.<br />
<br />
<!--<br />
The Quoted-Printable encoding as specified in RFC [http://RFC.net/rfc1521.html#p18 1521] is intended to represent data that largely consists of bytes that correspond to printable characters in the ASCII character set. It encodes the data in such a way that the resulting bytes are unlikely to be modified by mail transport. If the data being encoded are mostly ASCII text, the encoded form of the data remains largely recognizable by humans. Procedures to encode and decode Quoted-Printable can be found in unit MimeUtil.<br />
--><br />
<br />
==== Examples ====<br />
<!--<br />
Often used in many protocols is choosing for escape character 0x1B, and set high bit of the forbidden characters. While the set / reset is only a bit manipulation it is very CPU friendly, but choosing for 0x1B is mostly a bad choice in binary data, unless it is predictable that this character is not often used in it. Another disadvantage is the bad reading of the escaped characters in a log.<br />
<br />
Less often used in communications but in some cases better is to use readable characters for the escape as well for the replacements. For example you can use '\' as escape character and 'c' for 0x13 and 'n' for 0x10 as it is a well known behaviour in C programming language.<br />
<br />
When data is containing many unreadable characters mixed with readable characters, and it has to be logged then it could be better to do a kind of a mix of previous techniques. Forbidden characters as well as non printable characters can be displayed in hex-ASCII and preceded by an escape character. For example 'hello '#10 will look like: 'hello%20%0A' if we choose for '%' as escape character.<br />
--><br />
<br />
== Packet mode ==<br />
<br />
=== Preceding each data packet with his length ===<br />
<br />
This is a very common used technique. The first 1, 2 o 4 bytes of the data represent the length of the packet. Note that it is common habitude in communications to represent the length header in [[Endian | Big Endian]] format while Intel CPU use by design [[Endian | Little Endian]] format.<br />
<br />
Less used but also a good technique is to represent the preceding length in hex format of 2, 4 or 8 bytes. Advantage is that this part of the header is human readable.<br />
<br />
=== Fixed length data ===<br />
<br />
== Mixed mode ==<br />
<br />
== Conclusion ==<br />
<br />
Difficult to explain something :)<br />
<br />
<br />
[[User:Wilfried|Wilfried]] 20:18, 21 February 2006 (CET)</div>Wilfriedhttp://wiki.overbyte.eu/wiki/index.php?title=Sending_and_receiving_data&diff=1888Sending and receiving data2006-02-25T18:14:49Z<p>Wilfried: /* General */</p>
<hr />
<div>[[Main_Page | Main page]] -> [[FAQ]] -> [[Sending and receiving data]]<br />
<br />
== General ==<br />
<br />
There are several ways to transfer data. No matter if it is a file, an image, textual or raw data, it is all the same. What is needed is a common language between the data sender and the data receiver, in order for each to understand the other. This language defines a format. Formatting data is a way to "shape" it, describing its beginning and its end, in order for the receiver to know where data starts and ends.<br />
<br />
<!--<br />
We use the term ''binary data'' not to make a difference to ''ASCII'' or human readable data, but for data that has an unpredictable content, meaning we cannot use line mode just like that because whatever combination of characters you choose it ''could'' be in the data stream itself.<br />
<br />
== Solutions ==<br />
--><br />
<br />
Many formats are of course possible, mainly depending upon the kind of data itself. Basically, we can consider that we have two kinds of data :<br />
* predictable data content<br />
* unpredictable data content<br />
<br />
In the first case, we know what kind of content the data contains - ie the byte set that can be used is known (byte values from 32 to 127, for example). In the other case, the data content is not known - ie the byte set can be any possible byte value (from 0 to 255). This major difference will mostly determine the format of the data to be exchanged, defining then the protocol.<br />
<br />
Concerning Predictable Data Content, as the content values are known by advance - a subset of the 256 possible byte values, it is possible to know which byte values '''cannot''' be part of the data. This hint let us the possibility to create a delimiter made of one or more of these "extra data" byte values. This delimiter, sent after data, may then help us to know where data ends. This mode where a delimiter is placed at the end of data is named LineMode.<br />
<br />
Concerning Unpredictable Data Content, as the content values are never known by advance - byte set values starts at 0 and ends at 255, if we plan to send several data packet (for example several records) at once, then we have to tell the receiver the size of the data we're going to send for each packet. This mode to "format" data packet by prefixing it with its size is call PacketMode.<br />
<br />
And if we plan to send at the same time some Predictable Data Content and some Unpredictable Data Content, we can then imagine a combination of both mode.<br />
<br />
[[TWSocket]] has the ability to help you in implementing such a protocol. It is able to manage data using [[TWSocket.LineMode | LineMode]] and PacketMode (which is Non-LineMode).<br />
<br />
== Line mode ==<br />
<br />
=== Base-64 ===<br />
<br />
''Base64'' is an encoding process using a 64 letter alphabet where each letter representing 6 bits in the input stream. It is described in RFC [http://rfc.net/rfc2045.html#p24 2045]. All encoding and decoding procedures can be found in unit MimeUtil. The encoded data is about 33 percent larger and not human readable. Every character not used in the Base64 alphabet can be used as control character, including line end.<br />
<br />
=== ASCII-hex ===<br />
<br />
''ASCII-hex'' is used in many protocols. Every character is converted into his hexadecimal equivalent and sent as such. For example the string '123' is sent as '313233'. The encoded data is twice as long and difficult human readable. Every character except 0..9, A..F can be used as control character, including line end.<br />
<br />
=== Escaping ===<br />
<br />
Escaping is very often used. Control characters including line end has to be chosen in a way they are as less as possible in the original data. The principle is to precede the control characters with an escape character and replace them by other characters. Very often a NULL character is escaped as well. Most of the time the data is only a little longer than original and good human readable.<br />
<br />
====Quoted-Printable====<br />
<br />
The Quoted-Printable encoding as specified in RFC [http://RFC.net/rfc1521.html#p18 1521] is intended to represent data that largely consists of bytes that correspond to printable characters in the ASCII character set. It encodes the data in such a way that the resulting bytes are unlikely to be modified by mail transport. If the data being encoded are mostly ASCII text, the encoded form of the data remains largely recognizable by humans. Procedures to encode and decode Quoted-Printable can be found in unit MimeUtil.<br />
<br />
<br />
==== Examples ====<br />
<!--<br />
Often used in many protocols is choosing for escape character 0x1B, and set high bit of the forbidden characters. While the set / reset is only a bit manipulation it is very CPU friendly, but choosing for 0x1B is mostly a bad choice in binary data, unless it is predictable that this character is not often used in it. Another disadvantage is the bad reading of the escaped characters in a log.<br />
<br />
Less often used in communications but in some cases better is to use readable characters for the escape as well for the replacements. For example you can use '\' as escape character and 'c' for 0x13 and 'n' for 0x10 as it is a well known behaviour in C programming language.<br />
<br />
When data is containing many unreadable characters mixed with readable characters, and it has to be logged then it could be better to do a kind of a mix of previous techniques. Forbidden characters as well as non printable characters can be displayed in hex-ASCII and preceded by an escape character. For example 'hello '#10 will look like: 'hello%20%0A' if we choose for '%' as escape character.<br />
--><br />
<br />
== Packet mode ==<br />
<br />
=== Preceding each data packet with his length ===<br />
<br />
This is a very common used technique. The first 1, 2 o 4 bytes of the data represent the length of the packet. Note that it is common habitude in communications to represent the length header in [[Endian | Big Endian]] format while Intel CPU use by design [[Endian | Little Endian]] format.<br />
<br />
Less used but also a good technique is to represent the preceding length in hex format of 2, 4 or 8 bytes. Advantage is that this part of the header is human readable.<br />
<br />
=== Fixed length data ===<br />
<br />
== Mixed mode ==<br />
<br />
== Conclusion ==<br />
<br />
Difficult to explain something :)<br />
<br />
<br />
[[User:Wilfried|Wilfried]] 20:18, 21 February 2006 (CET)</div>Wilfriedhttp://wiki.overbyte.eu/wiki/index.php?title=TWSocketServer&diff=1887TWSocketServer2006-02-25T17:58:15Z<p>Wilfried: /* Overview */</p>
<hr />
<div>[[Main_Page | Main page]] -> [[ICS_Components_Reference | ICS component reference]] -> [[TWSocketServer]]<br />
<br />
== Overview ==<br />
<br />
{|<br />
| '''unit''' |||| WSocketS.pas<br />
|-<br />
| '''inheritance''' |||| [[TWSocket]]<br />
|}<br />
<br />
TWSocketServer will normally be used to listen on a given tcp port. When a client connect, it will instanciate a new TWSocketClient component to handle communication with client. Normally you will derive your own component from TWSocketClient to add private data and methods to handle your processing needs. You tell TWSocketServer which component class it has to instanciate using ClientClass property. You have to initialize each instances created to handle each client from OnClientConnect event handler. TWSocketServer maintain a list of connected clients. You can access it using Client[] indexed property. ClientCount property is the size of Client[] array.<br />
<br />
Since it is derived from [[TWSocket]], lots of properties and events are unused and not listed here. Properties and events that have a meaning in both server or client component are listed here.<br />
<br />
Note that TWSocketServer is only usable for incoming TCP connections. Use [[TWSocket]] if you need use UDP.<br />
<br />
== Properties ==<br />
<br />
{| <br />
| width="130" valign="top" | [[TWSocketServer.Addr | Addr]] |||| The interface to listen on.<br />
|-<br />
| valign="top" | [[TWSocketServer.Banner | Banner]] ||||<br />
|-<br />
| valign="top" | [[TWSocketServer.BannerTooBusy | BannerTooBusy]] ||||<br />
|-<br />
| valign="top" | [[TWSocketServer.Client | Client]] ||||<br />
|-<br />
| valign="top" | [[TWSocketServer.ClientClass | ClientClass]] ||||<br />
|-<br />
| valign="top" | [[TWSocketServer.ClientCount | ClientCount]] ||||<br />
|-<br />
| valign="top" | [[TWSocketServer.Handle | Handle]] ||||<br />
|-<br />
| valign="top" | [[TWSocketServer.HSocket | HSocket]] ||||<br />
|-<br />
| valign="top" | [[TWSocketServer.LastError | LastError]] ||||<br />
|-<br />
| valign="top" | [[TWSocketServer.ListenBacklog | ListenBacklog]] ||||<br />
|-<br />
| valign="top" | [[TWSocketServer.MaxClients | MaxClients]] ||||<br />
|-<br />
| valign="top" | [[TWSocketServer.Port | Port]] ||||<br />
|-<br />
| width="90" valign="top" | [[TWSocketServer.PortNum | PortNum]] ||||<br />
|-<br />
| valign="top" | [[TWSocketServer.Proto | Proto]] ||||<br />
|-<br />
| valign="top" | [[TWSocketServer.State | State]] |||| Align test<br />
|}<br />
<br />
== Methods ==<br />
<br />
{| <br />
| width="130" valign="top" | [[TWSocketServer.Abort | Abort]] |||| Align test<br />
|-<br />
| valign="top" | [[TWSocketServer.Close | Close]] ||||<br />
|-<br />
| valign="top" | [[TWSocketServer.CloseDelayed | CloseDelayed]] ||||<br />
|-<br />
| valign="top" | [[TWSocketServer.Create | Create]] ||||<br />
|-<br />
| valign="top" | [[TWSocketServer.Destroy | Destroy]] ||||<br />
|-<br />
| valign="top" | [[TWSocketServer.IsClient | IsClient]] ||||<br />
|-<br />
| valign="top" | [[TWSocketServer.Listen | Listen]] ||||<br />
|-<br />
| valign="top" | [[TWSocketServer.MessageLoop | MessageLoop]] ||||<br />
|-<br />
| valign="top" | [[TWSocketServer.MessagePump | MessagePump]] ||||<br />
|-<br />
| valign="top" | [[TWSocketServer.ProcessMessage | ProcessMessage]] ||||<br />
|-<br />
| valign="top" | [[TWSocketServer.ProcessMessages | ProcessMessages]] ||||<br />
|-<br />
| valign="top" | [[TWSocketServer.Release | Release]] ||||<br />
|-<br />
| valign="top" | [[TWSocketServer.ThreadAttach | ThreadAttach]] ||||<br />
|-<br />
| valign="top" | [[TWSocketServer.ThreadDetach | ThreadDetach]] |||| Align test<br />
|}<br />
<br />
== Events ==<br />
<br />
{|<br />
| width="130" valign="top" | [[TWSocketServer.OnBgException | OnBgException]] |||| Align test<br />
|-<br />
| valign="top" | [[TWSocketServer.OnChangeState | OnChangeState]] ||||<br />
|-<br />
| valign="top" | [[TWSocketServer.OnClientConnect | OnClientConnect]] ||||<br />
|-<br />
| valign="top" | [[TWSocketServer.OnClientCreate | OnClientCreate]] ||||<br />
|-<br />
| valign="top" | [[TWSocketServer.OnClientDisconnect | OnClientDisconnect]] ||||<br />
|-<br />
| valign="top" | [[TWSocketServer.OnError | OnError]] ||||<br />
|-<br />
| valign="top" | [[TWSocketServer.OnMessagePump | OnMessagePump]] ||||<br />
|}<br />
<br />
== How to ==<br />
<br />
* [[TWSocketServer.HowTo.Stop listening | Stop accepting connections]]<br />
<br />
{{Components_Footer}}</div>Wilfriedhttp://wiki.overbyte.eu/wiki/index.php?title=TWSocket.Addr&diff=1886TWSocket.Addr2006-02-25T17:56:55Z<p>Wilfried: /* Client */</p>
<hr />
<div>[[Main_Page | Main page]] -> [[ICS_Components_Reference | ICS component reference]] -> [[TWSocket]] -> [[TWSocket.Addr | Addr]]<br />
<br />
== Definition ==<br />
<br />
'''property''' Addr: '''string''';<br />
<br />
== Description ==<br />
<br />
=== Client ===<br />
<br />
The host to connect to. It can be a dotted IP address or a hostname. If it is a dotted IP address then [[TWSocket.Connect | Connect]] will return immediatly, if it is a hostname it will block until the hostname is resolved, so [[TWSocket.DNSLookup | DNSLookup]] is perferable.<br />
<br />
=== Server ===<br />
<br />
The interface to listen on. ''0.0.0.0'' means all interfaces. Note that for a TCP server the use of [[TWSocketServer]] is preferable.<br />
<br />
== Example ==<br />
<br />
== Best practices ==<br />
<br />
== How to ==<br />
<br />
* Listen on multiple interfaces<br />
<br />
:You may listen on one interface (giving his IP address) or all interfaces (giving 0.0.0.0 as IP address). To listen to several IP addresses but not all, you have to use a TWSocket for each interface you want to listen to. Just use the same event handler for all your TWSocket components and of course always use sender argument in all those event handlers.<br />
<br />
:Note that this counts for a UDP listener and that for a TCP server the use of [[TWSocketServer]] is preferable.</div>Wilfriedhttp://wiki.overbyte.eu/wiki/index.php?title=TWSocket&diff=1885TWSocket2006-02-25T17:55:39Z<p>Wilfried: </p>
<hr />
<div>[[Main_Page | Main page]] -> [[ICS_Components_Reference | ICS component reference]] -> [[TWSocket]]<br />
== Overview ==<br />
<br />
{|<br />
| '''unit''' |||| WSocket.pas<br />
|-<br />
| '''inheritance''' ||||<br />
|}<br />
<br />
TWSocket component is implementing the TCP protocol described in RFC [http://rfc.net/rfc793.html 793] and and UDP protocol described in RFC [http://rfc.net/rfc768.html 768]. Both protocols are encaptulated by the IP protocol described in RFC [http://rfc.net/rfc791.html 791]. TWSocket is used in almost every other ICS component.<br />
<br />
TWSocket component can be used as client or a server. For its use as TCP server however [[TWSocketServer]] is encouraged because of his advanced features.<br />
<br />
== Properties ==<br />
<br />
{| <br />
| width="140" valign="top" | [[TWSocket.Addr | Addr]] |||| ''Client:'' The host to connect to. ''Server:'' The interface to listen on.<br />
|-<br />
| valign="top" | [[TWSocket.AllSent | AllSent]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.BufSize | BufSize]] |||| Size in bytes for send dynamic buffer cell.<br />
|-<br />
| valign="top" | [[TWSocket.ComponentOptions | ComponentOptions]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.DnsResult | DnsResult]] |||| Typically called in [[TWSocket.OnDnsLookupDone | OnDnsLookupDone]]. The IP address of the remote host given as argument to [[TWSocket.DnsLookup | DnsLookup]].<br />
|-<br />
| valign="top" | [[TWSocket.DnsResultList | DnsResultList]] |||| Similar to [[TWSocket.DnsResult | DnsResult]] but a TStringList containing the multiple IP's of the host if appropriate.<br />
|-<br />
| valign="top" | [[TWSocket.FlushTimeout | FlushTimeout]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Handle | Handle]] |||| Handle for the underlaying hidden window.<br />
|-<br />
| valign="top" | [[TWSocket.HSocket | HSocket]] |||| Winsock handle for underlaying socket.<br />
|-<br />
| valign="top" | [[TWSocket.IcsLogger | IcsLogger]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LastError | LastError]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LineEcho | LineEcho]] |||| Echo all received characters back to tramitter.<br />
|-<br />
| valign="top" | [[TWSocket.LineEdit | LineEdit]] |||| Handle received control characters used for editing.<br />
|-<br />
| valign="top" | [[TWSocket.LineEnd | LineEnd]] |||| End of line character(s) used ot trigger [[TWSocket.OnDataAvailable | OnDataAvailable]].<br />
|-<br />
| valign="top" | [[TWSocket.LineLength | LineLength]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LineLimit | LineLimit]] |||| Maximum line lenght to receive before triggering [[TWSocket.OnLineLimitExceeded | OnLineLimitExceeded]]. See also [[DOS attac]].<br />
|-<br />
| valign="top" | [[TWSocket.LineMode | LineMode]] |||| Use [[TWSocket.LineEnd | LineEnd]] as end of line marker to trigger [[TWSocket.OnDataAvailable | OnDataAvailable]].<br />
|-<br />
| valign="top" | [[TWSocket.LingerOnOff | LingerOnOff]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LingerTimeout | LingerTimeout]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ListenBacklog | ListenBacklog]] |||| <br />
|-<br />
| valign="top" | [[TWSocket.LocalAddr | LocalAddr]] |||| The local address where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.LocalPort | LocalPort]] |||| The local port where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.MultiCast | MultiCast]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MultiCastAddrStr | MultiCastAddrStr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MultiCastIpTTL | MultiCastIpTTL]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MultiThreaded | MultiThreaded]] |||| Set when TWSocket has to use his own message pump.<br />
|-<br />
| valign="top" | [[TWSocket.PeerAddr | PeerAddr]] |||| The remote address where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.PeerPort | PeerPort]] |||| The remote port port where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.Port | Port]] |||| ''Client:'' The port to connect to. ''Server:'' The port to listen on.<br />
|-<br />
| width="90" valign="top" | [[TWSocket.PortNum | PortNum]] |||| Integer value of [[TWSocket.Port | Port]].<br />
|-<br />
| valign="top" | [[TWSocket.Proto | Proto]] |||| The protocol to use, can be '''tcp''' or '''tcp'''.<br />
|-<br />
| valign="top" | [[TWSocket.RcvdCnt | RcvdCnt]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.RcvdCount | RcvdCount]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.RcvdPtr | RcvdPtr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReadCount | ReadCount]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReqVerLow | ReqVerLow]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReqVerHigh | ReqVerHigh]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReuseAddr | ReuseAddr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SendFlags | SendFlags]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksAuthentication | SocksAuthentication]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksLevel | SocksLevel]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksPassword | SocksPassword]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksPort | SocksPort]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksServer | SocksServer]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksUsercode | SocksUsercode]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.State | State]] |||| Current state of the socket, mainly used for log or display purposes.<br />
|-<br />
| valign="top" | [[TWSocket.Terminated | Terminated]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Text | Text]] ||||<br />
|}<br />
<br />
== Methods ==<br />
<br />
{| <br />
| width="140" valign="top" | [[TWSocket.Abort | Abort]] |||| Quick and dirty way to close the socket.<br />
|-<br />
| valign="top" | [[TWSocket.Accept | Accept]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.CancelDnsLookup | CancelDnsLookup]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Close | Close]] |||| Close the socket gracefull.<br />
|-<br />
| valign="top" | [[TWSocket.CloseDelayed | CloseDelayed]] |||| Close the socket gracefull in a message handler.<br />
|-<br />
| valign="top" | [[TWSocket.Connect | Connect]] |||| Connect to a remote host.<br />
|-<br />
| valign="top" | [[TWSocket.Create | Create]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.DeleteBufferedData | DeleteBufferedData]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Destroy | Destroy]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.DnsLookup | DnsLookup]] |||| Perform a DNS lookup of a hostname in background. See also [[TWSocket.OnDNSLookupDone | OnDNSLookupDone]].<br />
|-<br />
| valign="top" | [[TWSocket.Dup | Dup]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Flush | Flush]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetPeerAddr | GetPeerAddr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetPeerName | GetPeerName]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetPeerPort | GetPeerPort]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetSockName | GetSockName]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetXAddr | GetXAddr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetXPort | GetXPort]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Listen | Listen]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MessageLoop | MessageLoop]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MessagePump | MessagePump]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Pause | Pause]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.PeekData | PeekData]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ProcessMessage | ProcessMessage]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ProcessMessages | ProcessMessages]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.PutDataInSendBuffer | PutDataInSendBuffer]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.PutStringInSendBuffer | PutStringInSendBuffer]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Receive | Receive]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReceiveFrom | ReceiveFrom]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReceiveStr | ReceiveStr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Release | Release]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Resume | Resume]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReverseDnsLookup | ReverseDnsLookup]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Send | Send]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SendStr | SendStr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SendTo | SendTo]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SetLingerOption | SetLingerOption]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Shutdown | Shutdown]] |||| Close the socket gracefull.<br />
|-<br />
| valign="top" | [[TWSocket.TimerClear | TimerClear]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.TimerCmp | TimerCmp]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.TimerIsSet | TimerIsSet]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ThreadAttach | ThreadAttach]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ThreadDetach | ThreadDetach]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.WaitForClose | WaitForClose]] |||| Align test<br />
|}<br />
<br />
== Events ==<br />
<br />
{|<br />
| width="140" valign="top" | [[TWSocket.OnBgException | OnBgException]] |||| Background exception occured.<br />
|-<br />
| valign="top" | [[TWSocket.OnChangeState | OnChangeState]] |||| State of TWSocket has changed.<br />
|-<br />
| valign="top" | [[TWSocket.OnDataAvailable | OnDataAvailable]] |||| Data available in internal receive buffer.<br />
|-<br />
| valign="top" | [[TWSocket.OnDataSent | OnDataSent]] |||| Internal sent buffer is completely delivered to winsock.<br />
|-<br />
| width="90" valign="top" | [[TWSocket.OnDebugDisplay | OnDebugDisplay]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.OnDnsLookupDone | OnDnsLookupDone]] |||| [[TWSocket.DNSLookup | DNSLookup]] has finished.<br />
|-<br />
| valign="top" | [[TWSocket.OnError | OnError]] |||| ''Discouraged'', use exception handling instead.<br />
|-<br />
| valign="top" | [[TWSocket.OnLineLimitExceeded | OnLineLimitExceeded]] |||| Denial of service attack<br />
|-<br />
| valign="top" | [[TWSocket.OnMessagePump | OnMessagePump]] |||| To call your own message pump.<br />
|-<br />
| valign="top" | [[TWSocket.OnSendData | OnSendData]] |||| Winsock send buffer is empty, will be filled again by internal send buffer if still data available to send.<br />
|-<br />
| valign="top" | [[TWSocket.OnSessionAvailable | OnSessionAvailable]] |||| Client connected to this server.<br />
|-<br />
| valign="top" | [[TWSocket.OnSessionClosed | OnSessionClosed]] |||| Socket has closed.<br />
|-<br />
| valign="top" | [[TWSocket.OnSessionConnected | OnSessionConnected]] |||| Session to host etablished.<br />
|-<br />
| valign="top" | [[TWSocket.OnSocksAuthState | OnSocksAuthState]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.OnSocksConnected | OnSocksConnected]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.OnSocksError | OnSocksError]] ||||<br />
|}<br />
<br />
== How to ==<br />
<br />
* [[TWSocket.HowTo.Close | Close a TCP session]]<br />
* [[TWSocket.HowTo.Close | Destroy a dynamicly created TWSocket]]<br />
<br />
{{Components_Footer}}</div>Wilfriedhttp://wiki.overbyte.eu/wiki/index.php?title=TWSocketServer.Addr&diff=1884TWSocketServer.Addr2006-02-25T17:46:49Z<p>Wilfried: /* Description */</p>
<hr />
<div>[[Main_Page | Main page]] -> [[ICS_Components_Reference | ICS component reference]] -> [[TWSocketServer]] -> [[TWSocketServer.Addr | Addr]]<br />
<br />
== Definition ==<br />
<br />
'''property''' Addr: '''string''';<br />
<br />
== Description ==<br />
<br />
The IP address of interface to listen on. ''0.0.0.0'' means all interfaces.<br />
<br />
== Example ==<br />
<br />
== Best practices ==<br />
<br />
== How to ==<br />
* Listen on multiple interfaces<br />
<br />
:You may listen on one interface (giving his IP address) or all interfaces (giving 0.0.0.0 as IP address). To listen to several IP addresses but not all, you have to use a TWSocketServer for each interface you want to listen to. Just use the same event handler for all your TWSocketServer components and of course always use sender argument in all those event handlers.</div>Wilfriedhttp://wiki.overbyte.eu/wiki/index.php?title=TWSocket.Addr&diff=1883TWSocket.Addr2006-02-25T17:46:15Z<p>Wilfried: /* Server */</p>
<hr />
<div>[[Main_Page | Main page]] -> [[ICS_Components_Reference | ICS component reference]] -> [[TWSocket]] -> [[TWSocket.Addr | Addr]]<br />
<br />
== Definition ==<br />
<br />
'''property''' Addr: '''string''';<br />
<br />
== Description ==<br />
<br />
=== Client ===<br />
<br />
The host to connect to. It can be a dotted IP address or a hostname. If it is a dotted IP address then '''Connect''' will return immediatly, if it is a hostname it will block until the hostname is resolved, so '''DNSLookUp''' is perferable.<br />
<br />
=== Server ===<br />
<br />
The interface to listen on. ''0.0.0.0'' means all interfaces. Note that for a TCP server the use of [[TWSocketServer]] is preferable.<br />
<br />
== Example ==<br />
<br />
== Best practices ==<br />
<br />
== How to ==<br />
<br />
* Listen on multiple interfaces<br />
<br />
:You may listen on one interface (giving his IP address) or all interfaces (giving 0.0.0.0 as IP address). To listen to several IP addresses but not all, you have to use a TWSocket for each interface you want to listen to. Just use the same event handler for all your TWSocket components and of course always use sender argument in all those event handlers.<br />
<br />
:Note that this counts for a UDP listener and that for a TCP server the use of [[TWSocketServer]] is preferable.</div>Wilfriedhttp://wiki.overbyte.eu/wiki/index.php?title=TWSocket.Addr&diff=1882TWSocket.Addr2006-02-25T17:45:58Z<p>Wilfried: /* Client */</p>
<hr />
<div>[[Main_Page | Main page]] -> [[ICS_Components_Reference | ICS component reference]] -> [[TWSocket]] -> [[TWSocket.Addr | Addr]]<br />
<br />
== Definition ==<br />
<br />
'''property''' Addr: '''string''';<br />
<br />
== Description ==<br />
<br />
=== Client ===<br />
<br />
The host to connect to. It can be a dotted IP address or a hostname. If it is a dotted IP address then '''Connect''' will return immediatly, if it is a hostname it will block until the hostname is resolved, so '''DNSLookUp''' is perferable.<br />
<br />
=== Server ===<br />
<br />
The interface to listen on. '''0.0.0.0''' means all interfaces. Note that for a TCP server the use of [[TWSocketServer]] is preferable.<br />
<br />
== Example ==<br />
<br />
== Best practices ==<br />
<br />
== How to ==<br />
<br />
* Listen on multiple interfaces<br />
<br />
:You may listen on one interface (giving his IP address) or all interfaces (giving 0.0.0.0 as IP address). To listen to several IP addresses but not all, you have to use a TWSocket for each interface you want to listen to. Just use the same event handler for all your TWSocket components and of course always use sender argument in all those event handlers.<br />
<br />
:Note that this counts for a UDP listener and that for a TCP server the use of [[TWSocketServer]] is preferable.</div>Wilfriedhttp://wiki.overbyte.eu/wiki/index.php?title=TWSocket.Addr&diff=1881TWSocket.Addr2006-02-25T17:45:41Z<p>Wilfried: /* Client */</p>
<hr />
<div>[[Main_Page | Main page]] -> [[ICS_Components_Reference | ICS component reference]] -> [[TWSocket]] -> [[TWSocket.Addr | Addr]]<br />
<br />
== Definition ==<br />
<br />
'''property''' Addr: '''string''';<br />
<br />
== Description ==<br />
<br />
=== Client ===<br />
<br />
The host to connect to. It can be a dotted IP address or a hostname. If it is a dotted IP address then '''Connect'' will return immediatly, if it is a hostname it will block until the hostname is resolved, so '''DNSLookUp''' is perferable.<br />
<br />
=== Server ===<br />
<br />
The interface to listen on. '''0.0.0.0''' means all interfaces. Note that for a TCP server the use of [[TWSocketServer]] is preferable.<br />
<br />
== Example ==<br />
<br />
== Best practices ==<br />
<br />
== How to ==<br />
<br />
* Listen on multiple interfaces<br />
<br />
:You may listen on one interface (giving his IP address) or all interfaces (giving 0.0.0.0 as IP address). To listen to several IP addresses but not all, you have to use a TWSocket for each interface you want to listen to. Just use the same event handler for all your TWSocket components and of course always use sender argument in all those event handlers.<br />
<br />
:Note that this counts for a UDP listener and that for a TCP server the use of [[TWSocketServer]] is preferable.</div>Wilfriedhttp://wiki.overbyte.eu/wiki/index.php?title=TWSocketServer&diff=1880TWSocketServer2006-02-25T17:44:03Z<p>Wilfried: /* How to */</p>
<hr />
<div>[[Main_Page | Main page]] -> [[ICS_Components_Reference | ICS component reference]] -> [[TWSocketServer]]<br />
<br />
== Overview ==<br />
<br />
*'''unit''' WSocketS.pas<br />
*'''inheritance''' [[TWSocket]]<br />
<br />
TWSocketServer will normally be used to listen on a given tcp port. When a client connect, it will instanciate a new TWSocketClient component to handle communication with client. Normally you will derive your own component from TWSocketClient to add private data and methods to handle your processing needs. You tell TWSocketServer which component class it has to instanciate using ClientClass property. You have to initialize each instances created to handle each client from OnClientConnect event handler. TWSocketServer maintain a list of connected clients. You can access it using Client[] indexed property. ClientCount property is the size of Client[] array.<br />
<br />
Since it is derived from [[TWSocket]], lots of properties and events are unused and not listed here. Properties and events that have a meaning in both server or client component are listed here.<br />
<br />
Note that TWSocketServer is only usable for incoming TCP connections. Use [[TWSocket]] if you need use UDP.<br />
<br />
== Properties ==<br />
<br />
{| <br />
| width="130" valign="top" | [[TWSocketServer.Addr | Addr]] |||| The interface to listen on.<br />
|-<br />
| valign="top" | [[TWSocketServer.Banner | Banner]] ||||<br />
|-<br />
| valign="top" | [[TWSocketServer.BannerTooBusy | BannerTooBusy]] ||||<br />
|-<br />
| valign="top" | [[TWSocketServer.Client | Client]] ||||<br />
|-<br />
| valign="top" | [[TWSocketServer.ClientClass | ClientClass]] ||||<br />
|-<br />
| valign="top" | [[TWSocketServer.ClientCount | ClientCount]] ||||<br />
|-<br />
| valign="top" | [[TWSocketServer.Handle | Handle]] ||||<br />
|-<br />
| valign="top" | [[TWSocketServer.HSocket | HSocket]] ||||<br />
|-<br />
| valign="top" | [[TWSocketServer.LastError | LastError]] ||||<br />
|-<br />
| valign="top" | [[TWSocketServer.ListenBacklog | ListenBacklog]] ||||<br />
|-<br />
| valign="top" | [[TWSocketServer.MaxClients | MaxClients]] ||||<br />
|-<br />
| valign="top" | [[TWSocketServer.Port | Port]] ||||<br />
|-<br />
| width="90" valign="top" | [[TWSocketServer.PortNum | PortNum]] ||||<br />
|-<br />
| valign="top" | [[TWSocketServer.Proto | Proto]] ||||<br />
|-<br />
| valign="top" | [[TWSocketServer.State | State]] |||| Align test<br />
|}<br />
<br />
== Methods ==<br />
<br />
{| <br />
| width="130" valign="top" | [[TWSocketServer.Abort | Abort]] |||| Align test<br />
|-<br />
| valign="top" | [[TWSocketServer.Close | Close]] ||||<br />
|-<br />
| valign="top" | [[TWSocketServer.CloseDelayed | CloseDelayed]] ||||<br />
|-<br />
| valign="top" | [[TWSocketServer.Create | Create]] ||||<br />
|-<br />
| valign="top" | [[TWSocketServer.Destroy | Destroy]] ||||<br />
|-<br />
| valign="top" | [[TWSocketServer.IsClient | IsClient]] ||||<br />
|-<br />
| valign="top" | [[TWSocketServer.Listen | Listen]] ||||<br />
|-<br />
| valign="top" | [[TWSocketServer.MessageLoop | MessageLoop]] ||||<br />
|-<br />
| valign="top" | [[TWSocketServer.MessagePump | MessagePump]] ||||<br />
|-<br />
| valign="top" | [[TWSocketServer.ProcessMessage | ProcessMessage]] ||||<br />
|-<br />
| valign="top" | [[TWSocketServer.ProcessMessages | ProcessMessages]] ||||<br />
|-<br />
| valign="top" | [[TWSocketServer.Release | Release]] ||||<br />
|-<br />
| valign="top" | [[TWSocketServer.ThreadAttach | ThreadAttach]] ||||<br />
|-<br />
| valign="top" | [[TWSocketServer.ThreadDetach | ThreadDetach]] |||| Align test<br />
|}<br />
<br />
== Events ==<br />
<br />
{|<br />
| width="130" valign="top" | [[TWSocketServer.OnBgException | OnBgException]] |||| Align test<br />
|-<br />
| valign="top" | [[TWSocketServer.OnChangeState | OnChangeState]] ||||<br />
|-<br />
| valign="top" | [[TWSocketServer.OnClientConnect | OnClientConnect]] ||||<br />
|-<br />
| valign="top" | [[TWSocketServer.OnClientCreate | OnClientCreate]] ||||<br />
|-<br />
| valign="top" | [[TWSocketServer.OnClientDisconnect | OnClientDisconnect]] ||||<br />
|-<br />
| valign="top" | [[TWSocketServer.OnError | OnError]] ||||<br />
|-<br />
| valign="top" | [[TWSocketServer.OnMessagePump | OnMessagePump]] ||||<br />
|}<br />
<br />
== How to ==<br />
<br />
* [[TWSocketServer.HowTo.Stop listening | Stop accepting connections]]<br />
<br />
{{Components_Footer}}</div>Wilfriedhttp://wiki.overbyte.eu/wiki/index.php?title=TWSocket&diff=1879TWSocket2006-02-25T17:41:01Z<p>Wilfried: /* How to */</p>
<hr />
<div>[[Main_Page | Main page]] -> [[ICS_Components_Reference | ICS component reference]] -> [[TWSocket]]<br />
== Overview ==<br />
<br />
{|<br />
| '''unit''' |||| WSocket.pas<br />
|-<br />
| '''inheritance''' ||||<br />
|}<br />
<br />
TWSocket component is implementing the TCP protocol described in RFC [http://rfc.net/rfc793.html 793] and and UDP protocol described in RFC [http://rfc.net/rfc768.html 768]. Both protocols are encaptulated by the IP protocol described in RFC [http://rfc.net/rfc791.html 791]. TWSocket is used in almost every other ICS component.<br />
<br />
TWSocket component can be used as client or a server. For its use as TCP server however [[TWSocketServer]] is encouraged because of his advanced features.<br />
<br />
== Properties ==<br />
<br />
{| <br />
| width="140" valign="top" | [[TWSocket.Addr | Addr]] |||| ''Client:'' The host to connect to. ''Server:'' The interface to listen on.<br />
|-<br />
| valign="top" | [[TWSocket.AllSent | AllSent]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.BufSize | BufSize]] |||| Size in bytes for send dynamic buffer cell.<br />
|-<br />
| valign="top" | [[TWSocket.ComponentOptions | ComponentOptions]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.DnsResult | DnsResult]] |||| Typically called in '''OnDnsLookupDone'''. The IP address of the remote host given as argument to '''DnsLookup'''.<br />
|-<br />
| valign="top" | [[TWSocket.DnsResultList | DnsResultList]] |||| Similar to '''DnsResult''' but a TStringList containing the multiple IP's of the host if appropriate.<br />
|-<br />
| valign="top" | [[TWSocket.FlushTimeout | FlushTimeout]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Handle | Handle]] |||| Handle for the underlaying hidden window.<br />
|-<br />
| valign="top" | [[TWSocket.HSocket | HSocket]] |||| Winsock handle for underlaying socket.<br />
|-<br />
| valign="top" | [[TWSocket.IcsLogger | IcsLogger]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LastError | LastError]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LineEcho | LineEcho]] |||| Echo all received characters back to tramitter.<br />
|-<br />
| valign="top" | [[TWSocket.LineEdit | LineEdit]] |||| Handle received control characters used for editing.<br />
|-<br />
| valign="top" | [[TWSocket.LineEnd | LineEnd]] |||| End of line character(s) used ot trigger '''OnDataAvailable'''.<br />
|-<br />
| valign="top" | [[TWSocket.LineLength | LineLength]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LineLimit | LineLimit]] |||| Maximum line lenght to receive before triggering '''OnLineLimitExceeded'''. See also [[DOS attac]].<br />
|-<br />
| valign="top" | [[TWSocket.LineMode | LineMode]] |||| Use '''LineEnd''' as end of line marker to trigger '''OnDataAvailable'''.<br />
|-<br />
| valign="top" | [[TWSocket.LingerOnOff | LingerOnOff]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LingerTimeout | LingerTimeout]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ListenBacklog | ListenBacklog]] |||| <br />
|-<br />
| valign="top" | [[TWSocket.LocalAddr | LocalAddr]] |||| The local address where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.LocalPort | LocalPort]] |||| The local port where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.MultiCast | MultiCast]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MultiCastAddrStr | MultiCastAddrStr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MultiCastIpTTL | MultiCastIpTTL]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MultiThreaded | MultiThreaded]] |||| Set when TWSocket has to use his own message pump.<br />
|-<br />
| valign="top" | [[TWSocket.PeerAddr | PeerAddr]] |||| The remote address where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.PeerPort | PeerPort]] |||| The remote port port where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.Port | Port]] |||| ''Client:'' The port to connect to. ''Server:'' The port to listen on.<br />
|-<br />
| width="90" valign="top" | [[TWSocket.PortNum | PortNum]] |||| Integer value of '''Port'''.<br />
|-<br />
| valign="top" | [[TWSocket.Proto | Proto]] |||| The protocol to use, can be '''tcp''' or '''tcp'''.<br />
|-<br />
| valign="top" | [[TWSocket.RcvdCnt | RcvdCnt]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.RcvdCount | RcvdCount]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.RcvdPtr | RcvdPtr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReadCount | ReadCount]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReqVerLow | ReqVerLow]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReqVerHigh | ReqVerHigh]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReuseAddr | ReuseAddr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SendFlags | SendFlags]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksAuthentication | SocksAuthentication]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksLevel | SocksLevel]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksPassword | SocksPassword]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksPort | SocksPort]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksServer | SocksServer]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksUsercode | SocksUsercode]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.State | State]] |||| Current state of the socket, mainly used for log or display purposes.<br />
|-<br />
| valign="top" | [[TWSocket.Terminated | Terminated]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Text | Text]] ||||<br />
|}<br />
<br />
== Methods ==<br />
<br />
{| <br />
| width="140" valign="top" | [[TWSocket.Abort | Abort]] |||| Quick and dirty way to close the socket.<br />
|-<br />
| valign="top" | [[TWSocket.Accept | Accept]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.CancelDnsLookup | CancelDnsLookup]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Close | Close]] |||| Close the socket gracefull.<br />
|-<br />
| valign="top" | [[TWSocket.CloseDelayed | CloseDelayed]] |||| Close the socket gracefull in a message handler.<br />
|-<br />
| valign="top" | [[TWSocket.Connect | Connect]] |||| Connect to a remote host.<br />
|-<br />
| valign="top" | [[TWSocket.Create | Create]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.DeleteBufferedData | DeleteBufferedData]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Destroy | Destroy]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.DnsLookup | DnsLookup]] |||| Perform a DNS lookup of a hostname in background. See also '''OnDNSLookupDone'''.<br />
|-<br />
| valign="top" | [[TWSocket.Dup | Dup]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Flush | Flush]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetPeerAddr | GetPeerAddr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetPeerName | GetPeerName]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetPeerPort | GetPeerPort]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetSockName | GetSockName]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetXAddr | GetXAddr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetXPort | GetXPort]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Listen | Listen]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MessageLoop | MessageLoop]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MessagePump | MessagePump]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Pause | Pause]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.PeekData | PeekData]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ProcessMessage | ProcessMessage]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ProcessMessages | ProcessMessages]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.PutDataInSendBuffer | PutDataInSendBuffer]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.PutStringInSendBuffer | PutStringInSendBuffer]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Receive | Receive]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReceiveFrom | ReceiveFrom]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReceiveStr | ReceiveStr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Release | Release]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Resume | Resume]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReverseDnsLookup | ReverseDnsLookup]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Send | Send]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SendStr | SendStr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SendTo | SendTo]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SetLingerOption | SetLingerOption]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Shutdown | Shutdown]] |||| Close the socket gracefull.<br />
|-<br />
| valign="top" | [[TWSocket.TimerClear | TimerClear]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.TimerCmp | TimerCmp]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.TimerIsSet | TimerIsSet]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ThreadAttach | ThreadAttach]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ThreadDetach | ThreadDetach]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.WaitForClose | WaitForClose]] |||| Align test<br />
|}<br />
<br />
== Events ==<br />
<br />
{|<br />
| width="140" valign="top" | [[TWSocket.OnBgException | OnBgException]] |||| Background exception occured.<br />
|-<br />
| valign="top" | [[TWSocket.OnChangeState | OnChangeState]] |||| State of TWSocket has changed.<br />
|-<br />
| valign="top" | [[TWSocket.OnDataAvailable | OnDataAvailable]] |||| Data available in internal receive buffer.<br />
|-<br />
| valign="top" | [[TWSocket.OnDataSent | OnDataSent]] |||| Internal sent buffer is completely delivered to winsock.<br />
|-<br />
| width="90" valign="top" | [[TWSocket.OnDebugDisplay | OnDebugDisplay]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.OnDnsLookupDone | OnDnsLookupDone]] |||| '''DNSLookup''' has finished.<br />
|-<br />
| valign="top" | [[TWSocket.OnError | OnError]] |||| ''Discouraged'', use exception handling instead.<br />
|-<br />
| valign="top" | [[TWSocket.OnLineLimitExceeded | OnLineLimitExceeded]] |||| Denial of service attack<br />
|-<br />
| valign="top" | [[TWSocket.OnMessagePump | OnMessagePump]] |||| To call your own message pump.<br />
|-<br />
| valign="top" | [[TWSocket.OnSendData | OnSendData]] |||| Winsock send buffer is empty, will be filled again by internal send buffer if still data available to send.<br />
|-<br />
| valign="top" | [[TWSocket.OnSessionAvailable | OnSessionAvailable]] |||| Client connected to this server.<br />
|-<br />
| valign="top" | [[TWSocket.OnSessionClosed | OnSessionClosed]] |||| Socket has closed.<br />
|-<br />
| valign="top" | [[TWSocket.OnSessionConnected | OnSessionConnected]] |||| Session to host etablished.<br />
|-<br />
| valign="top" | [[TWSocket.OnSocksAuthState | OnSocksAuthState]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.OnSocksConnected | OnSocksConnected]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.OnSocksError | OnSocksError]] ||||<br />
|}<br />
<br />
== How to ==<br />
<br />
* [[TWSocket.HowTo.Close | Close a TCP session]]<br />
* [[TWSocket.HowTo.Close | Destroy a dynamicly created TWSocket]]<br />
<br />
{{Components_Footer}}</div>Wilfriedhttp://wiki.overbyte.eu/wiki/index.php?title=TWSocket&diff=1878TWSocket2006-02-25T17:38:49Z<p>Wilfried: /* Events */</p>
<hr />
<div>[[Main_Page | Main page]] -> [[ICS_Components_Reference | ICS component reference]] -> [[TWSocket]]<br />
== Overview ==<br />
<br />
{|<br />
| '''unit''' |||| WSocket.pas<br />
|-<br />
| '''inheritance''' ||||<br />
|}<br />
<br />
TWSocket component is implementing the TCP protocol described in RFC [http://rfc.net/rfc793.html 793] and and UDP protocol described in RFC [http://rfc.net/rfc768.html 768]. Both protocols are encaptulated by the IP protocol described in RFC [http://rfc.net/rfc791.html 791]. TWSocket is used in almost every other ICS component.<br />
<br />
TWSocket component can be used as client or a server. For its use as TCP server however [[TWSocketServer]] is encouraged because of his advanced features.<br />
<br />
== Properties ==<br />
<br />
{| <br />
| width="140" valign="top" | [[TWSocket.Addr | Addr]] |||| ''Client:'' The host to connect to. ''Server:'' The interface to listen on.<br />
|-<br />
| valign="top" | [[TWSocket.AllSent | AllSent]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.BufSize | BufSize]] |||| Size in bytes for send dynamic buffer cell.<br />
|-<br />
| valign="top" | [[TWSocket.ComponentOptions | ComponentOptions]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.DnsResult | DnsResult]] |||| Typically called in '''OnDnsLookupDone'''. The IP address of the remote host given as argument to '''DnsLookup'''.<br />
|-<br />
| valign="top" | [[TWSocket.DnsResultList | DnsResultList]] |||| Similar to '''DnsResult''' but a TStringList containing the multiple IP's of the host if appropriate.<br />
|-<br />
| valign="top" | [[TWSocket.FlushTimeout | FlushTimeout]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Handle | Handle]] |||| Handle for the underlaying hidden window.<br />
|-<br />
| valign="top" | [[TWSocket.HSocket | HSocket]] |||| Winsock handle for underlaying socket.<br />
|-<br />
| valign="top" | [[TWSocket.IcsLogger | IcsLogger]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LastError | LastError]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LineEcho | LineEcho]] |||| Echo all received characters back to tramitter.<br />
|-<br />
| valign="top" | [[TWSocket.LineEdit | LineEdit]] |||| Handle received control characters used for editing.<br />
|-<br />
| valign="top" | [[TWSocket.LineEnd | LineEnd]] |||| End of line character(s) used ot trigger '''OnDataAvailable'''.<br />
|-<br />
| valign="top" | [[TWSocket.LineLength | LineLength]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LineLimit | LineLimit]] |||| Maximum line lenght to receive before triggering '''OnLineLimitExceeded'''. See also [[DOS attac]].<br />
|-<br />
| valign="top" | [[TWSocket.LineMode | LineMode]] |||| Use '''LineEnd''' as end of line marker to trigger '''OnDataAvailable'''.<br />
|-<br />
| valign="top" | [[TWSocket.LingerOnOff | LingerOnOff]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LingerTimeout | LingerTimeout]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ListenBacklog | ListenBacklog]] |||| <br />
|-<br />
| valign="top" | [[TWSocket.LocalAddr | LocalAddr]] |||| The local address where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.LocalPort | LocalPort]] |||| The local port where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.MultiCast | MultiCast]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MultiCastAddrStr | MultiCastAddrStr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MultiCastIpTTL | MultiCastIpTTL]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MultiThreaded | MultiThreaded]] |||| Set when TWSocket has to use his own message pump.<br />
|-<br />
| valign="top" | [[TWSocket.PeerAddr | PeerAddr]] |||| The remote address where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.PeerPort | PeerPort]] |||| The remote port port where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.Port | Port]] |||| ''Client:'' The port to connect to. ''Server:'' The port to listen on.<br />
|-<br />
| width="90" valign="top" | [[TWSocket.PortNum | PortNum]] |||| Integer value of '''Port'''.<br />
|-<br />
| valign="top" | [[TWSocket.Proto | Proto]] |||| The protocol to use, can be '''tcp''' or '''tcp'''.<br />
|-<br />
| valign="top" | [[TWSocket.RcvdCnt | RcvdCnt]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.RcvdCount | RcvdCount]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.RcvdPtr | RcvdPtr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReadCount | ReadCount]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReqVerLow | ReqVerLow]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReqVerHigh | ReqVerHigh]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReuseAddr | ReuseAddr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SendFlags | SendFlags]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksAuthentication | SocksAuthentication]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksLevel | SocksLevel]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksPassword | SocksPassword]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksPort | SocksPort]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksServer | SocksServer]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksUsercode | SocksUsercode]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.State | State]] |||| Current state of the socket, mainly used for log or display purposes.<br />
|-<br />
| valign="top" | [[TWSocket.Terminated | Terminated]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Text | Text]] ||||<br />
|}<br />
<br />
== Methods ==<br />
<br />
{| <br />
| width="140" valign="top" | [[TWSocket.Abort | Abort]] |||| Quick and dirty way to close the socket.<br />
|-<br />
| valign="top" | [[TWSocket.Accept | Accept]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.CancelDnsLookup | CancelDnsLookup]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Close | Close]] |||| Close the socket gracefull.<br />
|-<br />
| valign="top" | [[TWSocket.CloseDelayed | CloseDelayed]] |||| Close the socket gracefull in a message handler.<br />
|-<br />
| valign="top" | [[TWSocket.Connect | Connect]] |||| Connect to a remote host.<br />
|-<br />
| valign="top" | [[TWSocket.Create | Create]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.DeleteBufferedData | DeleteBufferedData]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Destroy | Destroy]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.DnsLookup | DnsLookup]] |||| Perform a DNS lookup of a hostname in background. See also '''OnDNSLookupDone'''.<br />
|-<br />
| valign="top" | [[TWSocket.Dup | Dup]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Flush | Flush]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetPeerAddr | GetPeerAddr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetPeerName | GetPeerName]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetPeerPort | GetPeerPort]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetSockName | GetSockName]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetXAddr | GetXAddr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetXPort | GetXPort]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Listen | Listen]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MessageLoop | MessageLoop]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MessagePump | MessagePump]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Pause | Pause]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.PeekData | PeekData]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ProcessMessage | ProcessMessage]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ProcessMessages | ProcessMessages]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.PutDataInSendBuffer | PutDataInSendBuffer]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.PutStringInSendBuffer | PutStringInSendBuffer]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Receive | Receive]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReceiveFrom | ReceiveFrom]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReceiveStr | ReceiveStr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Release | Release]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Resume | Resume]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReverseDnsLookup | ReverseDnsLookup]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Send | Send]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SendStr | SendStr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SendTo | SendTo]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SetLingerOption | SetLingerOption]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Shutdown | Shutdown]] |||| Close the socket gracefull.<br />
|-<br />
| valign="top" | [[TWSocket.TimerClear | TimerClear]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.TimerCmp | TimerCmp]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.TimerIsSet | TimerIsSet]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ThreadAttach | ThreadAttach]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ThreadDetach | ThreadDetach]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.WaitForClose | WaitForClose]] |||| Align test<br />
|}<br />
<br />
== Events ==<br />
<br />
{|<br />
| width="140" valign="top" | [[TWSocket.OnBgException | OnBgException]] |||| Background exception occured.<br />
|-<br />
| valign="top" | [[TWSocket.OnChangeState | OnChangeState]] |||| State of TWSocket has changed.<br />
|-<br />
| valign="top" | [[TWSocket.OnDataAvailable | OnDataAvailable]] |||| Data available in internal receive buffer.<br />
|-<br />
| valign="top" | [[TWSocket.OnDataSent | OnDataSent]] |||| Internal sent buffer is completely delivered to winsock.<br />
|-<br />
| width="90" valign="top" | [[TWSocket.OnDebugDisplay | OnDebugDisplay]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.OnDnsLookupDone | OnDnsLookupDone]] |||| '''DNSLookup''' has finished.<br />
|-<br />
| valign="top" | [[TWSocket.OnError | OnError]] |||| ''Discouraged'', use exception handling instead.<br />
|-<br />
| valign="top" | [[TWSocket.OnLineLimitExceeded | OnLineLimitExceeded]] |||| Denial of service attack<br />
|-<br />
| valign="top" | [[TWSocket.OnMessagePump | OnMessagePump]] |||| To call your own message pump.<br />
|-<br />
| valign="top" | [[TWSocket.OnSendData | OnSendData]] |||| Winsock send buffer is empty, will be filled again by internal send buffer if still data available to send.<br />
|-<br />
| valign="top" | [[TWSocket.OnSessionAvailable | OnSessionAvailable]] |||| Client connected to this server.<br />
|-<br />
| valign="top" | [[TWSocket.OnSessionClosed | OnSessionClosed]] |||| Socket has closed.<br />
|-<br />
| valign="top" | [[TWSocket.OnSessionConnected | OnSessionConnected]] |||| Session to host etablished.<br />
|-<br />
| valign="top" | [[TWSocket.OnSocksAuthState | OnSocksAuthState]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.OnSocksConnected | OnSocksConnected]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.OnSocksError | OnSocksError]] ||||<br />
|}<br />
<br />
== How to ==<br />
<br />
[[TWSocket.HowTo.Title | Title]]<br />
<br />
{{Components_Footer}}</div>Wilfriedhttp://wiki.overbyte.eu/wiki/index.php?title=TWSocket&diff=1877TWSocket2006-02-25T17:31:56Z<p>Wilfried: /* Methods */</p>
<hr />
<div>[[Main_Page | Main page]] -> [[ICS_Components_Reference | ICS component reference]] -> [[TWSocket]]<br />
== Overview ==<br />
<br />
{|<br />
| '''unit''' |||| WSocket.pas<br />
|-<br />
| '''inheritance''' ||||<br />
|}<br />
<br />
TWSocket component is implementing the TCP protocol described in RFC [http://rfc.net/rfc793.html 793] and and UDP protocol described in RFC [http://rfc.net/rfc768.html 768]. Both protocols are encaptulated by the IP protocol described in RFC [http://rfc.net/rfc791.html 791]. TWSocket is used in almost every other ICS component.<br />
<br />
TWSocket component can be used as client or a server. For its use as TCP server however [[TWSocketServer]] is encouraged because of his advanced features.<br />
<br />
== Properties ==<br />
<br />
{| <br />
| width="140" valign="top" | [[TWSocket.Addr | Addr]] |||| ''Client:'' The host to connect to. ''Server:'' The interface to listen on.<br />
|-<br />
| valign="top" | [[TWSocket.AllSent | AllSent]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.BufSize | BufSize]] |||| Size in bytes for send dynamic buffer cell.<br />
|-<br />
| valign="top" | [[TWSocket.ComponentOptions | ComponentOptions]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.DnsResult | DnsResult]] |||| Typically called in '''OnDnsLookupDone'''. The IP address of the remote host given as argument to '''DnsLookup'''.<br />
|-<br />
| valign="top" | [[TWSocket.DnsResultList | DnsResultList]] |||| Similar to '''DnsResult''' but a TStringList containing the multiple IP's of the host if appropriate.<br />
|-<br />
| valign="top" | [[TWSocket.FlushTimeout | FlushTimeout]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Handle | Handle]] |||| Handle for the underlaying hidden window.<br />
|-<br />
| valign="top" | [[TWSocket.HSocket | HSocket]] |||| Winsock handle for underlaying socket.<br />
|-<br />
| valign="top" | [[TWSocket.IcsLogger | IcsLogger]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LastError | LastError]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LineEcho | LineEcho]] |||| Echo all received characters back to tramitter.<br />
|-<br />
| valign="top" | [[TWSocket.LineEdit | LineEdit]] |||| Handle received control characters used for editing.<br />
|-<br />
| valign="top" | [[TWSocket.LineEnd | LineEnd]] |||| End of line character(s) used ot trigger '''OnDataAvailable'''.<br />
|-<br />
| valign="top" | [[TWSocket.LineLength | LineLength]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LineLimit | LineLimit]] |||| Maximum line lenght to receive before triggering '''OnLineLimitExceeded'''. See also [[DOS attac]].<br />
|-<br />
| valign="top" | [[TWSocket.LineMode | LineMode]] |||| Use '''LineEnd''' as end of line marker to trigger '''OnDataAvailable'''.<br />
|-<br />
| valign="top" | [[TWSocket.LingerOnOff | LingerOnOff]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LingerTimeout | LingerTimeout]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ListenBacklog | ListenBacklog]] |||| <br />
|-<br />
| valign="top" | [[TWSocket.LocalAddr | LocalAddr]] |||| The local address where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.LocalPort | LocalPort]] |||| The local port where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.MultiCast | MultiCast]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MultiCastAddrStr | MultiCastAddrStr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MultiCastIpTTL | MultiCastIpTTL]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MultiThreaded | MultiThreaded]] |||| Set when TWSocket has to use his own message pump.<br />
|-<br />
| valign="top" | [[TWSocket.PeerAddr | PeerAddr]] |||| The remote address where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.PeerPort | PeerPort]] |||| The remote port port where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.Port | Port]] |||| ''Client:'' The port to connect to. ''Server:'' The port to listen on.<br />
|-<br />
| width="90" valign="top" | [[TWSocket.PortNum | PortNum]] |||| Integer value of '''Port'''.<br />
|-<br />
| valign="top" | [[TWSocket.Proto | Proto]] |||| The protocol to use, can be '''tcp''' or '''tcp'''.<br />
|-<br />
| valign="top" | [[TWSocket.RcvdCnt | RcvdCnt]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.RcvdCount | RcvdCount]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.RcvdPtr | RcvdPtr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReadCount | ReadCount]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReqVerLow | ReqVerLow]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReqVerHigh | ReqVerHigh]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReuseAddr | ReuseAddr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SendFlags | SendFlags]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksAuthentication | SocksAuthentication]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksLevel | SocksLevel]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksPassword | SocksPassword]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksPort | SocksPort]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksServer | SocksServer]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksUsercode | SocksUsercode]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.State | State]] |||| Current state of the socket, mainly used for log or display purposes.<br />
|-<br />
| valign="top" | [[TWSocket.Terminated | Terminated]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Text | Text]] ||||<br />
|}<br />
<br />
== Methods ==<br />
<br />
{| <br />
| width="140" valign="top" | [[TWSocket.Abort | Abort]] |||| Quick and dirty way to close the socket.<br />
|-<br />
| valign="top" | [[TWSocket.Accept | Accept]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.CancelDnsLookup | CancelDnsLookup]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Close | Close]] |||| Close the socket gracefull.<br />
|-<br />
| valign="top" | [[TWSocket.CloseDelayed | CloseDelayed]] |||| Close the socket gracefull in a message handler.<br />
|-<br />
| valign="top" | [[TWSocket.Connect | Connect]] |||| Connect to a remote host.<br />
|-<br />
| valign="top" | [[TWSocket.Create | Create]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.DeleteBufferedData | DeleteBufferedData]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Destroy | Destroy]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.DnsLookup | DnsLookup]] |||| Perform a DNS lookup of a hostname in background. See also '''OnDNSLookupDone'''.<br />
|-<br />
| valign="top" | [[TWSocket.Dup | Dup]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Flush | Flush]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetPeerAddr | GetPeerAddr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetPeerName | GetPeerName]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetPeerPort | GetPeerPort]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetSockName | GetSockName]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetXAddr | GetXAddr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetXPort | GetXPort]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Listen | Listen]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MessageLoop | MessageLoop]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MessagePump | MessagePump]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Pause | Pause]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.PeekData | PeekData]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ProcessMessage | ProcessMessage]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ProcessMessages | ProcessMessages]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.PutDataInSendBuffer | PutDataInSendBuffer]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.PutStringInSendBuffer | PutStringInSendBuffer]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Receive | Receive]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReceiveFrom | ReceiveFrom]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReceiveStr | ReceiveStr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Release | Release]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Resume | Resume]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReverseDnsLookup | ReverseDnsLookup]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Send | Send]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SendStr | SendStr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SendTo | SendTo]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SetLingerOption | SetLingerOption]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Shutdown | Shutdown]] |||| Close the socket gracefull.<br />
|-<br />
| valign="top" | [[TWSocket.TimerClear | TimerClear]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.TimerCmp | TimerCmp]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.TimerIsSet | TimerIsSet]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ThreadAttach | ThreadAttach]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ThreadDetach | ThreadDetach]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.WaitForClose | WaitForClose]] |||| Align test<br />
|}<br />
<br />
== Events ==<br />
<br />
{|<br />
| width="140" valign="top" | [[TWSocket.OnBgException | OnBgException]] |||| Background exception occured.<br />
|-<br />
| valign="top" | [[TWSocket.OnChangeState | OnChangeState]] |||| State of TWSocket has changed.<br />
|-<br />
| valign="top" | [[TWSocket.OnDataAvailable | OnDataAvailable]] |||| Data available in internal receive buffer.<br />
|-<br />
| valign="top" | [[TWSocket.OnDataSent | OnDataSent]] |||| Internal sent buffer is completely delivered to winsock.<br />
|-<br />
| width="90" valign="top" | [[TWSocket.OnDebugDisplay | OnDebugDisplay]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.OnDnsLookupDone | OnDnsLookupDone]] |||| '''DNSLookup''' has finished.<br />
|-<br />
| valign="top" | [[TWSocket.OnError | OnError]] |||| '''Discouraged''', use exception handling instead.<br />
|-<br />
| valign="top" | [[TWSocket.OnLineLimitExceeded | OnLineLimitExceeded]] |||| Denial of service attack<br />
|-<br />
| valign="top" | [[TWSocket.OnMessagePump | OnMessagePump]] |||| To call your own message pump.<br />
|-<br />
| valign="top" | [[TWSocket.OnSendData | OnSendData]] |||| Winsock send buffer is empty, will be filled again by internal send buffer if still data available to send.<br />
|-<br />
| valign="top" | [[TWSocket.OnSessionAvailable | OnSessionAvailable]] |||| Client connected to this server.<br />
|-<br />
| valign="top" | [[TWSocket.OnSessionClosed | OnSessionClosed]] |||| Socket has closed.<br />
|-<br />
| valign="top" | [[TWSocket.OnSessionConnected | OnSessionConnected]] |||| Session to host etablished.<br />
|-<br />
| valign="top" | [[TWSocket.OnSocksAuthState | OnSocksAuthState]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.OnSocksConnected | OnSocksConnected]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.OnSocksError | OnSocksError]] ||||<br />
|}<br />
<br />
== How to ==<br />
<br />
[[TWSocket.HowTo.Title | Title]]<br />
<br />
{{Components_Footer}}</div>Wilfriedhttp://wiki.overbyte.eu/wiki/index.php?title=TWSocket&diff=1873TWSocket2006-02-25T17:04:00Z<p>Wilfried: /* Overview */</p>
<hr />
<div>[[Main_Page | Main page]] -> [[ICS_Components_Reference | ICS component reference]] -> [[TWSocket]]<br />
== Overview ==<br />
<br />
{|<br />
| '''unit''' |||| WSocket.pas<br />
|-<br />
| '''inheritance''' ||||<br />
|}<br />
<br />
TWSocket component is implementing the TCP protocol described in RFC [http://rfc.net/rfc793.html 793] and and UDP protocol described in RFC [http://rfc.net/rfc768.html 768]. Both protocols are encaptulated by the IP protocol described in RFC [http://rfc.net/rfc791.html 791]. TWSocket is used in almost every other ICS component.<br />
<br />
TWSocket component can be used as client or a server. For its use as TCP server however [[TWSocketServer]] is encouraged because of his advanced features.<br />
<br />
== Properties ==<br />
<br />
{| <br />
| width="140" valign="top" | [[TWSocket.Addr | Addr]] |||| ''Client:'' The host to connect to. ''Server:'' The interface to listen on.<br />
|-<br />
| valign="top" | [[TWSocket.AllSent | AllSent]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.BufSize | BufSize]] |||| Size in bytes for send dynamic buffer cell.<br />
|-<br />
| valign="top" | [[TWSocket.ComponentOptions | ComponentOptions]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.DnsResult | DnsResult]] |||| Typically called in '''OnDnsLookupDone'''. The IP address of the remote host given as argument to '''DnsLookup'''.<br />
|-<br />
| valign="top" | [[TWSocket.DnsResultList | DnsResultList]] |||| Similar to '''DnsResult''' but a TStringList containing the multiple IP's of the host if appropriate.<br />
|-<br />
| valign="top" | [[TWSocket.FlushTimeout | FlushTimeout]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Handle | Handle]] |||| Handle for the underlaying hidden window.<br />
|-<br />
| valign="top" | [[TWSocket.HSocket | HSocket]] |||| Winsock handle for underlaying socket.<br />
|-<br />
| valign="top" | [[TWSocket.IcsLogger | IcsLogger]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LastError | LastError]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LineEcho | LineEcho]] |||| Echo all received characters back to tramitter.<br />
|-<br />
| valign="top" | [[TWSocket.LineEdit | LineEdit]] |||| Handle received control characters used for editing.<br />
|-<br />
| valign="top" | [[TWSocket.LineEnd | LineEnd]] |||| End of line character(s) used ot trigger '''OnDataAvailable'''.<br />
|-<br />
| valign="top" | [[TWSocket.LineLength | LineLength]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LineLimit | LineLimit]] |||| Maximum line lenght to receive before triggering '''OnLineLimitExceeded'''. See also [[DOS attac]].<br />
|-<br />
| valign="top" | [[TWSocket.LineMode | LineMode]] |||| Use '''LineEnd''' as end of line marker to trigger '''OnDataAvailable'''.<br />
|-<br />
| valign="top" | [[TWSocket.LingerOnOff | LingerOnOff]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LingerTimeout | LingerTimeout]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ListenBacklog | ListenBacklog]] |||| <br />
|-<br />
| valign="top" | [[TWSocket.LocalAddr | LocalAddr]] |||| The local address where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.LocalPort | LocalPort]] |||| The local port where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.MultiCast | MultiCast]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MultiCastAddrStr | MultiCastAddrStr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MultiCastIpTTL | MultiCastIpTTL]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MultiThreaded | MultiThreaded]] |||| Set when TWSocket has to use his own message pump.<br />
|-<br />
| valign="top" | [[TWSocket.PeerAddr | PeerAddr]] |||| The remote address where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.PeerPort | PeerPort]] |||| The remote port port where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.Port | Port]] |||| ''Client:'' The port to connect to. ''Server:'' The port to listen on.<br />
|-<br />
| width="90" valign="top" | [[TWSocket.PortNum | PortNum]] |||| Integer value of '''Port'''.<br />
|-<br />
| valign="top" | [[TWSocket.Proto | Proto]] |||| The protocol to use, can be '''tcp''' or '''tcp'''.<br />
|-<br />
| valign="top" | [[TWSocket.RcvdCnt | RcvdCnt]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.RcvdCount | RcvdCount]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.RcvdPtr | RcvdPtr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReadCount | ReadCount]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReqVerLow | ReqVerLow]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReqVerHigh | ReqVerHigh]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReuseAddr | ReuseAddr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SendFlags | SendFlags]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksAuthentication | SocksAuthentication]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksLevel | SocksLevel]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksPassword | SocksPassword]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksPort | SocksPort]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksServer | SocksServer]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksUsercode | SocksUsercode]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.State | State]] |||| Current state of the socket, mainly used for log or display purposes.<br />
|-<br />
| valign="top" | [[TWSocket.Terminated | Terminated]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Text | Text]] ||||<br />
|}<br />
<br />
== Methods ==<br />
<br />
{| <br />
| width="140" valign="top" | [[TWSocket.Abort | Abort]] |||| Close the socket, see also [[Closing a TCP session]].<br />
|-<br />
| valign="top" | [[TWSocket.Accept | Accept]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.CancelDnsLookup | CancelDnsLookup]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Close | Close]] |||| Close the socket gracefull, see also [[Closing a TCP session]].<br />
|-<br />
| valign="top" | [[TWSocket.CloseDelayed | CloseDelayed]] |||| Close the socket gracefull in a message handler, see also [[Closing a TCP session]].<br />
|-<br />
| valign="top" | [[TWSocket.Connect | Connect]] |||| Connect to a remote host.<br />
|-<br />
| valign="top" | [[TWSocket.Create | Create]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.DeleteBufferedData | DeleteBufferedData]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Destroy | Destroy]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.DnsLookup | DnsLookup]] |||| Perform a DNS lookup of a hostname in background. See also '''OnDNSLookupDone'''.<br />
|-<br />
| valign="top" | [[TWSocket.Dup | Dup]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Flush | Flush]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetPeerAddr | GetPeerAddr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetPeerName | GetPeerName]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetPeerPort | GetPeerPort]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetSockName | GetSockName]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetXAddr | GetXAddr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetXPort | GetXPort]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Listen | Listen]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MessageLoop | MessageLoop]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MessagePump | MessagePump]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Pause | Pause]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.PeekData | PeekData]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ProcessMessage | ProcessMessage]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ProcessMessages | ProcessMessages]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.PutDataInSendBuffer | PutDataInSendBuffer]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.PutStringInSendBuffer | PutStringInSendBuffer]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Receive | Receive]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReceiveFrom | ReceiveFrom]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReceiveStr | ReceiveStr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Release | Release]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Resume | Resume]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReverseDnsLookup | ReverseDnsLookup]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Send | Send]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SendStr | SendStr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SendTo | SendTo]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SetLingerOption | SetLingerOption]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Shutdown | Shutdown]] |||| Close the socket gracefull, see also [[Closing a TCP session]].<br />
|-<br />
| valign="top" | [[TWSocket.TimerClear | TimerClear]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.TimerCmp | TimerCmp]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.TimerIsSet | TimerIsSet]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ThreadAttach | ThreadAttach]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ThreadDetach | ThreadDetach]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.WaitForClose | WaitForClose]] |||| Align test<br />
|}<br />
<br />
== Events ==<br />
<br />
{|<br />
| width="140" valign="top" | [[TWSocket.OnBgException | OnBgException]] |||| Background exception occured.<br />
|-<br />
| valign="top" | [[TWSocket.OnChangeState | OnChangeState]] |||| State of TWSocket has changed.<br />
|-<br />
| valign="top" | [[TWSocket.OnDataAvailable | OnDataAvailable]] |||| Data available in internal receive buffer.<br />
|-<br />
| valign="top" | [[TWSocket.OnDataSent | OnDataSent]] |||| Internal sent buffer is completely delivered to winsock.<br />
|-<br />
| width="90" valign="top" | [[TWSocket.OnDebugDisplay | OnDebugDisplay]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.OnDnsLookupDone | OnDnsLookupDone]] |||| '''DNSLookup''' has finished.<br />
|-<br />
| valign="top" | [[TWSocket.OnError | OnError]] |||| '''Discouraged''', use exception handling instead.<br />
|-<br />
| valign="top" | [[TWSocket.OnLineLimitExceeded | OnLineLimitExceeded]] |||| Denial of service attack<br />
|-<br />
| valign="top" | [[TWSocket.OnMessagePump | OnMessagePump]] |||| To call your own message pump.<br />
|-<br />
| valign="top" | [[TWSocket.OnSendData | OnSendData]] |||| Winsock send buffer is empty, will be filled again by internal send buffer if still data available to send.<br />
|-<br />
| valign="top" | [[TWSocket.OnSessionAvailable | OnSessionAvailable]] |||| Client connected to this server.<br />
|-<br />
| valign="top" | [[TWSocket.OnSessionClosed | OnSessionClosed]] |||| Socket has closed.<br />
|-<br />
| valign="top" | [[TWSocket.OnSessionConnected | OnSessionConnected]] |||| Session to host etablished.<br />
|-<br />
| valign="top" | [[TWSocket.OnSocksAuthState | OnSocksAuthState]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.OnSocksConnected | OnSocksConnected]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.OnSocksError | OnSocksError]] ||||<br />
|}<br />
<br />
== How to ==<br />
<br />
[[TWSocket.HowTo.Title | Title]]<br />
<br />
{{Components_Footer}}</div>Wilfriedhttp://wiki.overbyte.eu/wiki/index.php?title=TWSocket&diff=1872TWSocket2006-02-25T17:01:54Z<p>Wilfried: /* Events */</p>
<hr />
<div>[[Main_Page | Main page]] -> [[ICS_Components_Reference | ICS component reference]] -> [[TWSocket]]<br />
== Overview ==<br />
<br />
*'''unit''' WSocket.pas<br />
*'''inheritance'''<br />
<br />
TWSocket component is implementing the TCP protocol described in RFC [http://rfc.net/rfc793.html 793] and and UDP protocol described in RFC [http://rfc.net/rfc768.html 768]. Both protocols are encaptulated by the IP protocol described in RFC [http://rfc.net/rfc791.html 791]. TWSocket is used in almost every other ICS component.<br />
<br />
TWSocket component can be used as client or a server. For its use as TCP server however [[TWSocketServer]] is encouraged because of his advanced features.<br />
<br />
== Properties ==<br />
<br />
{| <br />
| width="140" valign="top" | [[TWSocket.Addr | Addr]] |||| ''Client:'' The host to connect to. ''Server:'' The interface to listen on.<br />
|-<br />
| valign="top" | [[TWSocket.AllSent | AllSent]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.BufSize | BufSize]] |||| Size in bytes for send dynamic buffer cell.<br />
|-<br />
| valign="top" | [[TWSocket.ComponentOptions | ComponentOptions]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.DnsResult | DnsResult]] |||| Typically called in '''OnDnsLookupDone'''. The IP address of the remote host given as argument to '''DnsLookup'''.<br />
|-<br />
| valign="top" | [[TWSocket.DnsResultList | DnsResultList]] |||| Similar to '''DnsResult''' but a TStringList containing the multiple IP's of the host if appropriate.<br />
|-<br />
| valign="top" | [[TWSocket.FlushTimeout | FlushTimeout]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Handle | Handle]] |||| Handle for the underlaying hidden window.<br />
|-<br />
| valign="top" | [[TWSocket.HSocket | HSocket]] |||| Winsock handle for underlaying socket.<br />
|-<br />
| valign="top" | [[TWSocket.IcsLogger | IcsLogger]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LastError | LastError]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LineEcho | LineEcho]] |||| Echo all received characters back to tramitter.<br />
|-<br />
| valign="top" | [[TWSocket.LineEdit | LineEdit]] |||| Handle received control characters used for editing.<br />
|-<br />
| valign="top" | [[TWSocket.LineEnd | LineEnd]] |||| End of line character(s) used ot trigger '''OnDataAvailable'''.<br />
|-<br />
| valign="top" | [[TWSocket.LineLength | LineLength]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LineLimit | LineLimit]] |||| Maximum line lenght to receive before triggering '''OnLineLimitExceeded'''. See also [[DOS attac]].<br />
|-<br />
| valign="top" | [[TWSocket.LineMode | LineMode]] |||| Use '''LineEnd''' as end of line marker to trigger '''OnDataAvailable'''.<br />
|-<br />
| valign="top" | [[TWSocket.LingerOnOff | LingerOnOff]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LingerTimeout | LingerTimeout]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ListenBacklog | ListenBacklog]] |||| <br />
|-<br />
| valign="top" | [[TWSocket.LocalAddr | LocalAddr]] |||| The local address where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.LocalPort | LocalPort]] |||| The local port where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.MultiCast | MultiCast]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MultiCastAddrStr | MultiCastAddrStr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MultiCastIpTTL | MultiCastIpTTL]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MultiThreaded | MultiThreaded]] |||| Set when TWSocket has to use his own message pump.<br />
|-<br />
| valign="top" | [[TWSocket.PeerAddr | PeerAddr]] |||| The remote address where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.PeerPort | PeerPort]] |||| The remote port port where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.Port | Port]] |||| ''Client:'' The port to connect to. ''Server:'' The port to listen on.<br />
|-<br />
| width="90" valign="top" | [[TWSocket.PortNum | PortNum]] |||| Integer value of '''Port'''.<br />
|-<br />
| valign="top" | [[TWSocket.Proto | Proto]] |||| The protocol to use, can be '''tcp''' or '''tcp'''.<br />
|-<br />
| valign="top" | [[TWSocket.RcvdCnt | RcvdCnt]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.RcvdCount | RcvdCount]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.RcvdPtr | RcvdPtr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReadCount | ReadCount]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReqVerLow | ReqVerLow]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReqVerHigh | ReqVerHigh]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReuseAddr | ReuseAddr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SendFlags | SendFlags]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksAuthentication | SocksAuthentication]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksLevel | SocksLevel]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksPassword | SocksPassword]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksPort | SocksPort]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksServer | SocksServer]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksUsercode | SocksUsercode]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.State | State]] |||| Current state of the socket, mainly used for log or display purposes.<br />
|-<br />
| valign="top" | [[TWSocket.Terminated | Terminated]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Text | Text]] ||||<br />
|}<br />
<br />
== Methods ==<br />
<br />
{| <br />
| width="140" valign="top" | [[TWSocket.Abort | Abort]] |||| Close the socket, see also [[Closing a TCP session]].<br />
|-<br />
| valign="top" | [[TWSocket.Accept | Accept]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.CancelDnsLookup | CancelDnsLookup]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Close | Close]] |||| Close the socket gracefull, see also [[Closing a TCP session]].<br />
|-<br />
| valign="top" | [[TWSocket.CloseDelayed | CloseDelayed]] |||| Close the socket gracefull in a message handler, see also [[Closing a TCP session]].<br />
|-<br />
| valign="top" | [[TWSocket.Connect | Connect]] |||| Connect to a remote host.<br />
|-<br />
| valign="top" | [[TWSocket.Create | Create]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.DeleteBufferedData | DeleteBufferedData]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Destroy | Destroy]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.DnsLookup | DnsLookup]] |||| Perform a DNS lookup of a hostname in background. See also '''OnDNSLookupDone'''.<br />
|-<br />
| valign="top" | [[TWSocket.Dup | Dup]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Flush | Flush]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetPeerAddr | GetPeerAddr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetPeerName | GetPeerName]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetPeerPort | GetPeerPort]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetSockName | GetSockName]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetXAddr | GetXAddr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetXPort | GetXPort]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Listen | Listen]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MessageLoop | MessageLoop]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MessagePump | MessagePump]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Pause | Pause]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.PeekData | PeekData]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ProcessMessage | ProcessMessage]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ProcessMessages | ProcessMessages]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.PutDataInSendBuffer | PutDataInSendBuffer]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.PutStringInSendBuffer | PutStringInSendBuffer]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Receive | Receive]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReceiveFrom | ReceiveFrom]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReceiveStr | ReceiveStr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Release | Release]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Resume | Resume]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReverseDnsLookup | ReverseDnsLookup]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Send | Send]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SendStr | SendStr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SendTo | SendTo]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SetLingerOption | SetLingerOption]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Shutdown | Shutdown]] |||| Close the socket gracefull, see also [[Closing a TCP session]].<br />
|-<br />
| valign="top" | [[TWSocket.TimerClear | TimerClear]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.TimerCmp | TimerCmp]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.TimerIsSet | TimerIsSet]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ThreadAttach | ThreadAttach]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ThreadDetach | ThreadDetach]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.WaitForClose | WaitForClose]] |||| Align test<br />
|}<br />
<br />
== Events ==<br />
<br />
{|<br />
| width="140" valign="top" | [[TWSocket.OnBgException | OnBgException]] |||| Background exception occured.<br />
|-<br />
| valign="top" | [[TWSocket.OnChangeState | OnChangeState]] |||| State of TWSocket has changed.<br />
|-<br />
| valign="top" | [[TWSocket.OnDataAvailable | OnDataAvailable]] |||| Data available in internal receive buffer.<br />
|-<br />
| valign="top" | [[TWSocket.OnDataSent | OnDataSent]] |||| Internal sent buffer is completely delivered to winsock.<br />
|-<br />
| width="90" valign="top" | [[TWSocket.OnDebugDisplay | OnDebugDisplay]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.OnDnsLookupDone | OnDnsLookupDone]] |||| '''DNSLookup''' has finished.<br />
|-<br />
| valign="top" | [[TWSocket.OnError | OnError]] |||| '''Discouraged''', use exception handling instead.<br />
|-<br />
| valign="top" | [[TWSocket.OnLineLimitExceeded | OnLineLimitExceeded]] |||| Denial of service attack<br />
|-<br />
| valign="top" | [[TWSocket.OnMessagePump | OnMessagePump]] |||| To call your own message pump.<br />
|-<br />
| valign="top" | [[TWSocket.OnSendData | OnSendData]] |||| Winsock send buffer is empty, will be filled again by internal send buffer if still data available to send.<br />
|-<br />
| valign="top" | [[TWSocket.OnSessionAvailable | OnSessionAvailable]] |||| Client connected to this server.<br />
|-<br />
| valign="top" | [[TWSocket.OnSessionClosed | OnSessionClosed]] |||| Socket has closed.<br />
|-<br />
| valign="top" | [[TWSocket.OnSessionConnected | OnSessionConnected]] |||| Session to host etablished.<br />
|-<br />
| valign="top" | [[TWSocket.OnSocksAuthState | OnSocksAuthState]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.OnSocksConnected | OnSocksConnected]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.OnSocksError | OnSocksError]] ||||<br />
|}<br />
<br />
== How to ==<br />
<br />
[[TWSocket.HowTo.Title | Title]]<br />
<br />
{{Components_Footer}}</div>Wilfriedhttp://wiki.overbyte.eu/wiki/index.php?title=TWSocket&diff=1871TWSocket2006-02-25T17:01:15Z<p>Wilfried: /* Methods */</p>
<hr />
<div>[[Main_Page | Main page]] -> [[ICS_Components_Reference | ICS component reference]] -> [[TWSocket]]<br />
== Overview ==<br />
<br />
*'''unit''' WSocket.pas<br />
*'''inheritance'''<br />
<br />
TWSocket component is implementing the TCP protocol described in RFC [http://rfc.net/rfc793.html 793] and and UDP protocol described in RFC [http://rfc.net/rfc768.html 768]. Both protocols are encaptulated by the IP protocol described in RFC [http://rfc.net/rfc791.html 791]. TWSocket is used in almost every other ICS component.<br />
<br />
TWSocket component can be used as client or a server. For its use as TCP server however [[TWSocketServer]] is encouraged because of his advanced features.<br />
<br />
== Properties ==<br />
<br />
{| <br />
| width="140" valign="top" | [[TWSocket.Addr | Addr]] |||| ''Client:'' The host to connect to. ''Server:'' The interface to listen on.<br />
|-<br />
| valign="top" | [[TWSocket.AllSent | AllSent]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.BufSize | BufSize]] |||| Size in bytes for send dynamic buffer cell.<br />
|-<br />
| valign="top" | [[TWSocket.ComponentOptions | ComponentOptions]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.DnsResult | DnsResult]] |||| Typically called in '''OnDnsLookupDone'''. The IP address of the remote host given as argument to '''DnsLookup'''.<br />
|-<br />
| valign="top" | [[TWSocket.DnsResultList | DnsResultList]] |||| Similar to '''DnsResult''' but a TStringList containing the multiple IP's of the host if appropriate.<br />
|-<br />
| valign="top" | [[TWSocket.FlushTimeout | FlushTimeout]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Handle | Handle]] |||| Handle for the underlaying hidden window.<br />
|-<br />
| valign="top" | [[TWSocket.HSocket | HSocket]] |||| Winsock handle for underlaying socket.<br />
|-<br />
| valign="top" | [[TWSocket.IcsLogger | IcsLogger]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LastError | LastError]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LineEcho | LineEcho]] |||| Echo all received characters back to tramitter.<br />
|-<br />
| valign="top" | [[TWSocket.LineEdit | LineEdit]] |||| Handle received control characters used for editing.<br />
|-<br />
| valign="top" | [[TWSocket.LineEnd | LineEnd]] |||| End of line character(s) used ot trigger '''OnDataAvailable'''.<br />
|-<br />
| valign="top" | [[TWSocket.LineLength | LineLength]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LineLimit | LineLimit]] |||| Maximum line lenght to receive before triggering '''OnLineLimitExceeded'''. See also [[DOS attac]].<br />
|-<br />
| valign="top" | [[TWSocket.LineMode | LineMode]] |||| Use '''LineEnd''' as end of line marker to trigger '''OnDataAvailable'''.<br />
|-<br />
| valign="top" | [[TWSocket.LingerOnOff | LingerOnOff]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LingerTimeout | LingerTimeout]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ListenBacklog | ListenBacklog]] |||| <br />
|-<br />
| valign="top" | [[TWSocket.LocalAddr | LocalAddr]] |||| The local address where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.LocalPort | LocalPort]] |||| The local port where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.MultiCast | MultiCast]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MultiCastAddrStr | MultiCastAddrStr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MultiCastIpTTL | MultiCastIpTTL]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MultiThreaded | MultiThreaded]] |||| Set when TWSocket has to use his own message pump.<br />
|-<br />
| valign="top" | [[TWSocket.PeerAddr | PeerAddr]] |||| The remote address where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.PeerPort | PeerPort]] |||| The remote port port where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.Port | Port]] |||| ''Client:'' The port to connect to. ''Server:'' The port to listen on.<br />
|-<br />
| width="90" valign="top" | [[TWSocket.PortNum | PortNum]] |||| Integer value of '''Port'''.<br />
|-<br />
| valign="top" | [[TWSocket.Proto | Proto]] |||| The protocol to use, can be '''tcp''' or '''tcp'''.<br />
|-<br />
| valign="top" | [[TWSocket.RcvdCnt | RcvdCnt]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.RcvdCount | RcvdCount]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.RcvdPtr | RcvdPtr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReadCount | ReadCount]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReqVerLow | ReqVerLow]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReqVerHigh | ReqVerHigh]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReuseAddr | ReuseAddr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SendFlags | SendFlags]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksAuthentication | SocksAuthentication]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksLevel | SocksLevel]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksPassword | SocksPassword]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksPort | SocksPort]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksServer | SocksServer]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksUsercode | SocksUsercode]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.State | State]] |||| Current state of the socket, mainly used for log or display purposes.<br />
|-<br />
| valign="top" | [[TWSocket.Terminated | Terminated]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Text | Text]] ||||<br />
|}<br />
<br />
== Methods ==<br />
<br />
{| <br />
| width="140" valign="top" | [[TWSocket.Abort | Abort]] |||| Close the socket, see also [[Closing a TCP session]].<br />
|-<br />
| valign="top" | [[TWSocket.Accept | Accept]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.CancelDnsLookup | CancelDnsLookup]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Close | Close]] |||| Close the socket gracefull, see also [[Closing a TCP session]].<br />
|-<br />
| valign="top" | [[TWSocket.CloseDelayed | CloseDelayed]] |||| Close the socket gracefull in a message handler, see also [[Closing a TCP session]].<br />
|-<br />
| valign="top" | [[TWSocket.Connect | Connect]] |||| Connect to a remote host.<br />
|-<br />
| valign="top" | [[TWSocket.Create | Create]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.DeleteBufferedData | DeleteBufferedData]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Destroy | Destroy]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.DnsLookup | DnsLookup]] |||| Perform a DNS lookup of a hostname in background. See also '''OnDNSLookupDone'''.<br />
|-<br />
| valign="top" | [[TWSocket.Dup | Dup]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Flush | Flush]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetPeerAddr | GetPeerAddr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetPeerName | GetPeerName]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetPeerPort | GetPeerPort]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetSockName | GetSockName]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetXAddr | GetXAddr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetXPort | GetXPort]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Listen | Listen]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MessageLoop | MessageLoop]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MessagePump | MessagePump]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Pause | Pause]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.PeekData | PeekData]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ProcessMessage | ProcessMessage]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ProcessMessages | ProcessMessages]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.PutDataInSendBuffer | PutDataInSendBuffer]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.PutStringInSendBuffer | PutStringInSendBuffer]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Receive | Receive]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReceiveFrom | ReceiveFrom]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReceiveStr | ReceiveStr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Release | Release]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Resume | Resume]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReverseDnsLookup | ReverseDnsLookup]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Send | Send]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SendStr | SendStr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SendTo | SendTo]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SetLingerOption | SetLingerOption]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Shutdown | Shutdown]] |||| Close the socket gracefull, see also [[Closing a TCP session]].<br />
|-<br />
| valign="top" | [[TWSocket.TimerClear | TimerClear]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.TimerCmp | TimerCmp]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.TimerIsSet | TimerIsSet]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ThreadAttach | ThreadAttach]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ThreadDetach | ThreadDetach]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.WaitForClose | WaitForClose]] |||| Align test<br />
|}<br />
<br />
== Events ==<br />
<br />
{|<br />
| width="140" valign="top" | [[TWSocket.OnBgException | OnBgException]] |||| Background exception occured.<br />
|-<br />
| valign="top" | [[TWSocket.OnChangeState | OnChangeState]] |||| State of TWSocket has changed.<br />
|-<br />
| valign="top" | [[TWSocket.OnDataAvailable | OnDataAvailable]] |||| Data available in internal receive buffer.<br />
|-<br />
| valign="top" | [[TWSocket.OnDataSent | OnDataSent]] |||| Internal sent buffer is completely delivered to winsock.<br />
|-<br />
| width="90" valign="top" | [[TWSocket.OnDebugDisplay | OnDebugDisplay]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.OnDnsLookupDone | OnDnsLookupDone]] |||| [[TWSocket.DNSLookup | DNSLookup]] has finished.<br />
|-<br />
| valign="top" | [[TWSocket.OnError | OnError]] |||| '''Discouraged''', use exception handling instead.<br />
|-<br />
| valign="top" | [[TWSocket.OnLineLimitExceeded | OnLineLimitExceeded]] |||| Denial of service attack<br />
|-<br />
| valign="top" | [[TWSocket.OnMessagePump | OnMessagePump]] |||| To call your own message pump.<br />
|-<br />
| valign="top" | [[TWSocket.OnSendData | OnSendData]] |||| Winsock send buffer is empty, will be filled again by internal send buffer if still data available to send.<br />
|-<br />
| valign="top" | [[TWSocket.OnSessionAvailable | OnSessionAvailable]] |||| Client connected to this server.<br />
|-<br />
| valign="top" | [[TWSocket.OnSessionClosed | OnSessionClosed]] |||| Socket has closed.<br />
|-<br />
| valign="top" | [[TWSocket.OnSessionConnected | OnSessionConnected]] |||| Session to host etablished.<br />
|-<br />
| valign="top" | [[TWSocket.OnSocksAuthState | OnSocksAuthState]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.OnSocksConnected | OnSocksConnected]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.OnSocksError | OnSocksError]] ||||<br />
|}<br />
<br />
== How to ==<br />
<br />
[[TWSocket.HowTo.Title | Title]]<br />
<br />
{{Components_Footer}}</div>Wilfriedhttp://wiki.overbyte.eu/wiki/index.php?title=TWSocket&diff=1870TWSocket2006-02-25T17:00:39Z<p>Wilfried: /* Properties */</p>
<hr />
<div>[[Main_Page | Main page]] -> [[ICS_Components_Reference | ICS component reference]] -> [[TWSocket]]<br />
== Overview ==<br />
<br />
*'''unit''' WSocket.pas<br />
*'''inheritance'''<br />
<br />
TWSocket component is implementing the TCP protocol described in RFC [http://rfc.net/rfc793.html 793] and and UDP protocol described in RFC [http://rfc.net/rfc768.html 768]. Both protocols are encaptulated by the IP protocol described in RFC [http://rfc.net/rfc791.html 791]. TWSocket is used in almost every other ICS component.<br />
<br />
TWSocket component can be used as client or a server. For its use as TCP server however [[TWSocketServer]] is encouraged because of his advanced features.<br />
<br />
== Properties ==<br />
<br />
{| <br />
| width="140" valign="top" | [[TWSocket.Addr | Addr]] |||| ''Client:'' The host to connect to. ''Server:'' The interface to listen on.<br />
|-<br />
| valign="top" | [[TWSocket.AllSent | AllSent]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.BufSize | BufSize]] |||| Size in bytes for send dynamic buffer cell.<br />
|-<br />
| valign="top" | [[TWSocket.ComponentOptions | ComponentOptions]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.DnsResult | DnsResult]] |||| Typically called in '''OnDnsLookupDone'''. The IP address of the remote host given as argument to '''DnsLookup'''.<br />
|-<br />
| valign="top" | [[TWSocket.DnsResultList | DnsResultList]] |||| Similar to '''DnsResult''' but a TStringList containing the multiple IP's of the host if appropriate.<br />
|-<br />
| valign="top" | [[TWSocket.FlushTimeout | FlushTimeout]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Handle | Handle]] |||| Handle for the underlaying hidden window.<br />
|-<br />
| valign="top" | [[TWSocket.HSocket | HSocket]] |||| Winsock handle for underlaying socket.<br />
|-<br />
| valign="top" | [[TWSocket.IcsLogger | IcsLogger]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LastError | LastError]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LineEcho | LineEcho]] |||| Echo all received characters back to tramitter.<br />
|-<br />
| valign="top" | [[TWSocket.LineEdit | LineEdit]] |||| Handle received control characters used for editing.<br />
|-<br />
| valign="top" | [[TWSocket.LineEnd | LineEnd]] |||| End of line character(s) used ot trigger '''OnDataAvailable'''.<br />
|-<br />
| valign="top" | [[TWSocket.LineLength | LineLength]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LineLimit | LineLimit]] |||| Maximum line lenght to receive before triggering '''OnLineLimitExceeded'''. See also [[DOS attac]].<br />
|-<br />
| valign="top" | [[TWSocket.LineMode | LineMode]] |||| Use '''LineEnd''' as end of line marker to trigger '''OnDataAvailable'''.<br />
|-<br />
| valign="top" | [[TWSocket.LingerOnOff | LingerOnOff]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LingerTimeout | LingerTimeout]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ListenBacklog | ListenBacklog]] |||| <br />
|-<br />
| valign="top" | [[TWSocket.LocalAddr | LocalAddr]] |||| The local address where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.LocalPort | LocalPort]] |||| The local port where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.MultiCast | MultiCast]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MultiCastAddrStr | MultiCastAddrStr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MultiCastIpTTL | MultiCastIpTTL]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MultiThreaded | MultiThreaded]] |||| Set when TWSocket has to use his own message pump.<br />
|-<br />
| valign="top" | [[TWSocket.PeerAddr | PeerAddr]] |||| The remote address where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.PeerPort | PeerPort]] |||| The remote port port where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.Port | Port]] |||| ''Client:'' The port to connect to. ''Server:'' The port to listen on.<br />
|-<br />
| width="90" valign="top" | [[TWSocket.PortNum | PortNum]] |||| Integer value of '''Port'''.<br />
|-<br />
| valign="top" | [[TWSocket.Proto | Proto]] |||| The protocol to use, can be '''tcp''' or '''tcp'''.<br />
|-<br />
| valign="top" | [[TWSocket.RcvdCnt | RcvdCnt]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.RcvdCount | RcvdCount]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.RcvdPtr | RcvdPtr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReadCount | ReadCount]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReqVerLow | ReqVerLow]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReqVerHigh | ReqVerHigh]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReuseAddr | ReuseAddr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SendFlags | SendFlags]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksAuthentication | SocksAuthentication]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksLevel | SocksLevel]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksPassword | SocksPassword]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksPort | SocksPort]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksServer | SocksServer]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksUsercode | SocksUsercode]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.State | State]] |||| Current state of the socket, mainly used for log or display purposes.<br />
|-<br />
| valign="top" | [[TWSocket.Terminated | Terminated]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Text | Text]] ||||<br />
|}<br />
<br />
== Methods ==<br />
<br />
{| <br />
| width="140" valign="top" | [[TWSocket.Abort | Abort]] |||| Close the socket, see also [[Closing a TCP session]].<br />
|-<br />
| valign="top" | [[TWSocket.Accept | Accept]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.CancelDnsLookup | CancelDnsLookup]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Close | Close]] |||| Close the socket gracefull, see also [[Closing a TCP session]].<br />
|-<br />
| valign="top" | [[TWSocket.CloseDelayed | CloseDelayed]] |||| Close the socket gracefull in a message handler, see also [[Closing a TCP session]].<br />
|-<br />
| valign="top" | [[TWSocket.Connect | Connect]] |||| Connect to a remote host.<br />
|-<br />
| valign="top" | [[TWSocket.Create | Create]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.DeleteBufferedData | DeleteBufferedData]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Destroy | Destroy]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.DnsLookup | DnsLookup]] |||| Perform a DNS lookup of a hostname in background. See also [[OnDNSLookupDone]].<br />
|-<br />
| valign="top" | [[TWSocket.Dup | Dup]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Flush | Flush]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetPeerAddr | GetPeerAddr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetPeerName | GetPeerName]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetPeerPort | GetPeerPort]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetSockName | GetSockName]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetXAddr | GetXAddr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetXPort | GetXPort]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Listen | Listen]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MessageLoop | MessageLoop]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MessagePump | MessagePump]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Pause | Pause]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.PeekData | PeekData]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ProcessMessage | ProcessMessage]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ProcessMessages | ProcessMessages]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.PutDataInSendBuffer | PutDataInSendBuffer]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.PutStringInSendBuffer | PutStringInSendBuffer]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Receive | Receive]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReceiveFrom | ReceiveFrom]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReceiveStr | ReceiveStr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Release | Release]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Resume | Resume]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReverseDnsLookup | ReverseDnsLookup]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Send | Send]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SendStr | SendStr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SendTo | SendTo]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SetLingerOption | SetLingerOption]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Shutdown | Shutdown]] |||| Close the socket gracefull, see also [[Closing a TCP session]].<br />
|-<br />
| valign="top" | [[TWSocket.TimerClear | TimerClear]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.TimerCmp | TimerCmp]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.TimerIsSet | TimerIsSet]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ThreadAttach | ThreadAttach]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ThreadDetach | ThreadDetach]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.WaitForClose | WaitForClose]] |||| Align test<br />
|}<br />
<br />
== Events ==<br />
<br />
{|<br />
| width="140" valign="top" | [[TWSocket.OnBgException | OnBgException]] |||| Background exception occured.<br />
|-<br />
| valign="top" | [[TWSocket.OnChangeState | OnChangeState]] |||| State of TWSocket has changed.<br />
|-<br />
| valign="top" | [[TWSocket.OnDataAvailable | OnDataAvailable]] |||| Data available in internal receive buffer.<br />
|-<br />
| valign="top" | [[TWSocket.OnDataSent | OnDataSent]] |||| Internal sent buffer is completely delivered to winsock.<br />
|-<br />
| width="90" valign="top" | [[TWSocket.OnDebugDisplay | OnDebugDisplay]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.OnDnsLookupDone | OnDnsLookupDone]] |||| [[TWSocket.DNSLookup | DNSLookup]] has finished.<br />
|-<br />
| valign="top" | [[TWSocket.OnError | OnError]] |||| '''Discouraged''', use exception handling instead.<br />
|-<br />
| valign="top" | [[TWSocket.OnLineLimitExceeded | OnLineLimitExceeded]] |||| Denial of service attack<br />
|-<br />
| valign="top" | [[TWSocket.OnMessagePump | OnMessagePump]] |||| To call your own message pump.<br />
|-<br />
| valign="top" | [[TWSocket.OnSendData | OnSendData]] |||| Winsock send buffer is empty, will be filled again by internal send buffer if still data available to send.<br />
|-<br />
| valign="top" | [[TWSocket.OnSessionAvailable | OnSessionAvailable]] |||| Client connected to this server.<br />
|-<br />
| valign="top" | [[TWSocket.OnSessionClosed | OnSessionClosed]] |||| Socket has closed.<br />
|-<br />
| valign="top" | [[TWSocket.OnSessionConnected | OnSessionConnected]] |||| Session to host etablished.<br />
|-<br />
| valign="top" | [[TWSocket.OnSocksAuthState | OnSocksAuthState]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.OnSocksConnected | OnSocksConnected]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.OnSocksError | OnSocksError]] ||||<br />
|}<br />
<br />
== How to ==<br />
<br />
[[TWSocket.HowTo.Title | Title]]<br />
<br />
{{Components_Footer}}</div>Wilfriedhttp://wiki.overbyte.eu/wiki/index.php?title=TWSocket&diff=1869TWSocket2006-02-25T16:56:06Z<p>Wilfried: </p>
<hr />
<div>[[Main_Page | Main page]] -> [[ICS_Components_Reference | ICS component reference]] -> [[TWSocket]]<br />
== Overview ==<br />
<br />
*'''unit''' WSocket.pas<br />
*'''inheritance'''<br />
<br />
TWSocket component is implementing the TCP protocol described in RFC [http://rfc.net/rfc793.html 793] and and UDP protocol described in RFC [http://rfc.net/rfc768.html 768]. Both protocols are encaptulated by the IP protocol described in RFC [http://rfc.net/rfc791.html 791]. TWSocket is used in almost every other ICS component.<br />
<br />
TWSocket component can be used as client or a server. For its use as TCP server however [[TWSocketServer]] is encouraged because of his advanced features.<br />
<br />
== Properties ==<br />
<br />
{| <br />
| width="140" valign="top" | [[TWSocket.Addr | Addr]] |||| ''Client:'' The host to connect to. ''Server:'' The interface to listen on.<br />
|-<br />
| valign="top" | [[TWSocket.AllSent | AllSent]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.BufSize | BufSize]] |||| Size in bytes for send dynamic buffer cell.<br />
|-<br />
| valign="top" | [[TWSocket.ComponentOptions | ComponentOptions]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.DnsResult | DnsResult]] |||| Typically called in [[WSocket.OnDnsLookupDone | OnDnsLookupDone]]. The IP address of the remote host given as argument to [[TWSocket.DnsLookup | DnsLookup]].<br />
|-<br />
| valign="top" | [[TWSocket.DnsResultList | DnsResultList]] |||| Similar to [[TWSocket.DnsResult | DnsResult]] but a TStringList containing the multiple IP's of the host if appropriate.<br />
|-<br />
| valign="top" | [[TWSocket.FlushTimeout | FlushTimeout]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Handle | Handle]] |||| Handle for the underlaying hidden window.<br />
|-<br />
| valign="top" | [[TWSocket.HSocket | HSocket]] |||| Winsock handle for underlaying socket.<br />
|-<br />
| valign="top" | [[TWSocket.IcsLogger | IcsLogger]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LastError | LastError]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LineEcho | LineEcho]] |||| Echo all received characters back to tramitter.<br />
|-<br />
| valign="top" | [[TWSocket.LineEdit | LineEdit]] |||| Handle received control characters used for editing.<br />
|-<br />
| valign="top" | [[TWSocket.LineEnd | LineEnd]] |||| End of line character(s) used ot trigger [[TWSocket.OnDataAvailable | OnDataAvailable]].<br />
|-<br />
| valign="top" | [[TWSocket.LineLength | LineLength]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LineLimit | LineLimit]] |||| Maximum line lenght to receive before triggering [[OnLineLimitExceeded]]. See also [[DOS attac]].<br />
|-<br />
| valign="top" | [[TWSocket.LineMode | LineMode]] |||| Use [[LineEnd]] as end of line marker to trigger [[OnDataAvailable]].<br />
|-<br />
| valign="top" | [[TWSocket.LingerOnOff | LingerOnOff]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LingerTimeout | LingerTimeout]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ListenBacklog | ListenBacklog]] |||| <br />
|-<br />
| valign="top" | [[TWSocket.LocalAddr | LocalAddr]] |||| The local address where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.LocalPort | LocalPort]] |||| The local port where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.MultiCast | MultiCast]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MultiCastAddrStr | MultiCastAddrStr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MultiCastIpTTL | MultiCastIpTTL]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MultiThreaded | MultiThreaded]] |||| Set when TWSocket has to use his own message pump.<br />
|-<br />
| valign="top" | [[TWSocket.PeerAddr | PeerAddr]] |||| The remote address where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.PeerPort | PeerPort]] |||| The remote port port where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.Port | Port]] |||| ''Client:'' The port to connect to. ''Server:'' The port to listen on.<br />
|-<br />
| width="90" valign="top" | [[TWSocket.PortNum | PortNum]] |||| Integer value of [[WSSocket.Port | Port]].<br />
|-<br />
| valign="top" | [[TWSocket.Proto | Proto]] |||| The protocol to use, can be '''tcp''' or '''tcp'''.<br />
|-<br />
| valign="top" | [[TWSocket.RcvdCnt | RcvdCnt]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.RcvdCount | RcvdCount]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.RcvdPtr | RcvdPtr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReadCount | ReadCount]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReqVerLow | ReqVerLow]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReqVerHigh | ReqVerHigh]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReuseAddr | ReuseAddr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SendFlags | SendFlags]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksAuthentication | SocksAuthentication]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksLevel | SocksLevel]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksPassword | SocksPassword]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksPort | SocksPort]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksServer | SocksServer]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksUsercode | SocksUsercode]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.State | State]] |||| Current state of the socket, mainly used for log or display purposes.<br />
|-<br />
| valign="top" | [[TWSocket.Terminated | Terminated]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Text | Text]] ||||<br />
|}<br />
<br />
== Methods ==<br />
<br />
{| <br />
| width="140" valign="top" | [[TWSocket.Abort | Abort]] |||| Close the socket, see also [[Closing a TCP session]].<br />
|-<br />
| valign="top" | [[TWSocket.Accept | Accept]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.CancelDnsLookup | CancelDnsLookup]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Close | Close]] |||| Close the socket gracefull, see also [[Closing a TCP session]].<br />
|-<br />
| valign="top" | [[TWSocket.CloseDelayed | CloseDelayed]] |||| Close the socket gracefull in a message handler, see also [[Closing a TCP session]].<br />
|-<br />
| valign="top" | [[TWSocket.Connect | Connect]] |||| Connect to a remote host.<br />
|-<br />
| valign="top" | [[TWSocket.Create | Create]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.DeleteBufferedData | DeleteBufferedData]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Destroy | Destroy]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.DnsLookup | DnsLookup]] |||| Perform a DNS lookup of a hostname in background. See also [[OnDNSLookupDone]].<br />
|-<br />
| valign="top" | [[TWSocket.Dup | Dup]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Flush | Flush]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetPeerAddr | GetPeerAddr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetPeerName | GetPeerName]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetPeerPort | GetPeerPort]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetSockName | GetSockName]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetXAddr | GetXAddr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetXPort | GetXPort]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Listen | Listen]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MessageLoop | MessageLoop]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MessagePump | MessagePump]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Pause | Pause]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.PeekData | PeekData]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ProcessMessage | ProcessMessage]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ProcessMessages | ProcessMessages]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.PutDataInSendBuffer | PutDataInSendBuffer]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.PutStringInSendBuffer | PutStringInSendBuffer]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Receive | Receive]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReceiveFrom | ReceiveFrom]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReceiveStr | ReceiveStr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Release | Release]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Resume | Resume]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReverseDnsLookup | ReverseDnsLookup]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Send | Send]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SendStr | SendStr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SendTo | SendTo]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SetLingerOption | SetLingerOption]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Shutdown | Shutdown]] |||| Close the socket gracefull, see also [[Closing a TCP session]].<br />
|-<br />
| valign="top" | [[TWSocket.TimerClear | TimerClear]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.TimerCmp | TimerCmp]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.TimerIsSet | TimerIsSet]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ThreadAttach | ThreadAttach]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ThreadDetach | ThreadDetach]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.WaitForClose | WaitForClose]] |||| Align test<br />
|}<br />
<br />
== Events ==<br />
<br />
{|<br />
| width="140" valign="top" | [[TWSocket.OnBgException | OnBgException]] |||| Background exception occured.<br />
|-<br />
| valign="top" | [[TWSocket.OnChangeState | OnChangeState]] |||| State of TWSocket has changed.<br />
|-<br />
| valign="top" | [[TWSocket.OnDataAvailable | OnDataAvailable]] |||| Data available in internal receive buffer.<br />
|-<br />
| valign="top" | [[TWSocket.OnDataSent | OnDataSent]] |||| Internal sent buffer is completely delivered to winsock.<br />
|-<br />
| width="90" valign="top" | [[TWSocket.OnDebugDisplay | OnDebugDisplay]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.OnDnsLookupDone | OnDnsLookupDone]] |||| [[TWSocket.DNSLookup | DNSLookup]] has finished.<br />
|-<br />
| valign="top" | [[TWSocket.OnError | OnError]] |||| '''Discouraged''', use exception handling instead.<br />
|-<br />
| valign="top" | [[TWSocket.OnLineLimitExceeded | OnLineLimitExceeded]] |||| Denial of service attack<br />
|-<br />
| valign="top" | [[TWSocket.OnMessagePump | OnMessagePump]] |||| To call your own message pump.<br />
|-<br />
| valign="top" | [[TWSocket.OnSendData | OnSendData]] |||| Winsock send buffer is empty, will be filled again by internal send buffer if still data available to send.<br />
|-<br />
| valign="top" | [[TWSocket.OnSessionAvailable | OnSessionAvailable]] |||| Client connected to this server.<br />
|-<br />
| valign="top" | [[TWSocket.OnSessionClosed | OnSessionClosed]] |||| Socket has closed.<br />
|-<br />
| valign="top" | [[TWSocket.OnSessionConnected | OnSessionConnected]] |||| Session to host etablished.<br />
|-<br />
| valign="top" | [[TWSocket.OnSocksAuthState | OnSocksAuthState]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.OnSocksConnected | OnSocksConnected]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.OnSocksError | OnSocksError]] ||||<br />
|}<br />
<br />
== How to ==<br />
<br />
[[TWSocket.HowTo.Title | Title]]<br />
<br />
{{Components_Footer}}</div>Wilfriedhttp://wiki.overbyte.eu/wiki/index.php?title=TWSocket&diff=1868TWSocket2006-02-25T16:46:18Z<p>Wilfried: /* Properties */</p>
<hr />
<div>[[Main_Page | Main page]] -> [[ICS_Components_Reference | ICS component reference]] -> [[TWSocket]]<br />
== Overview ==<br />
<br />
*'''unit''' WSocket.pas<br />
*'''inheritance'''<br />
<br />
TWSocket component is implementing the TCP protocol described in RFC [http://rfc.net/rfc793.html 793] and and UDP protocol described in RFC [http://rfc.net/rfc768.html 768]. Both protocols are encaptulated by the IP protocol described in RFC [http://rfc.net/rfc791.html 791]. TWSocket is used in almost every other ICS component.<br />
<br />
TWSocket component can be used as client or a server. For its use as TCP server however [[TWSocketServer]] is encouraged because of his advanced features.<br />
<br />
== Properties ==<br />
<br />
{| <br />
| width="140" valign="top" | [[TWSocket.Addr | Addr]] |||| ''Client:'' The host to connect to. ''Server:'' The interface to listen on.<br />
|-<br />
| valign="top" | [[TWSocket.AllSent | AllSent]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.BufSize | BufSize]] |||| Size in bytes for send dynamic buffer cell.<br />
|-<br />
| valign="top" | [[TWSocket.ComponentOptions | ComponentOptions]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.DnsResult | DnsResult]] |||| Typically called in [[TWSocket.OnDnsLookupDone | OnDnsLookupDone]]. The IP address of the remote host given as argument to [[TWSocket.DnsLookup | DnsLookup]].<br />
|-<br />
| valign="top" | [[TWSocket.DnsResultList | DnsResultList]] |||| Similar to [[TWSocket.DnsResult | DnsResult]] but a TStringList containing the multiple IP's of the host if appropriate.<br />
|-<br />
| valign="top" | [[TWSocket.FlushTimeout | FlushTimeout]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Handle | Handle]] |||| Handle for the underlaying hidden window.<br />
|-<br />
| valign="top" | [[TWSocket.HSocket | HSocket]] |||| Winsock handle for underlaying socket.<br />
|-<br />
| valign="top" | [[TWSocket.IcsLogger | IcsLogger]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LastError | LastError]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LineEcho | LineEcho]] |||| Echo all received characters back to tramitter.<br />
|-<br />
| valign="top" | [[TWSocket.LineEdit | LineEdit]] |||| Handle received control characters used for editing.<br />
|-<br />
| valign="top" | [[TWSocket.LineEnd | LineEnd]] |||| End of line character(s) used ot trigger [[TWSocket.OnDataAvailable | OnDataAvailable]].<br />
|-<br />
| valign="top" | [[TWSocket.LineLength | LineLength]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LineLimit | LineLimit]] |||| Maximum line lenght to receive before triggering [[OnLineLimitExceeded]]. See also [[DOS attac]].<br />
|-<br />
| valign="top" | [[TWSocket.LineMode | LineMode]] |||| Use [[LineEnd]] as end of line marker to trigger [[OnDataAvailable]].<br />
|-<br />
| valign="top" | [[TWSocket.LingerOnOff | LingerOnOff]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LingerTimeout | LingerTimeout]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ListenBacklog | ListenBacklog]] |||| <br />
|-<br />
| valign="top" | [[TWSocket.LocalAddr | LocalAddr]] |||| The local address where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.LocalPort | LocalPort]] |||| The local port where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.MultiCast | MultiCast]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MultiCastAddrStr | MultiCastAddrStr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MultiCastIpTTL | MultiCastIpTTL]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MultiThreaded | MultiThreaded]] |||| Set when TWSocket has to use his own message pump.<br />
|-<br />
| valign="top" | [[TWSocket.PeerAddr | PeerAddr]] |||| The remote address where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.PeerPort | PeerPort]] |||| The remote port port where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.Port | Port]] |||| ''Client:'' The port to connect to. ''Server:'' The port to listen on.<br />
|-<br />
| width="90" valign="top" | [[TWSocket.PortNum | PortNum]] |||| Integer value of [[WSSocket.Port | Port]].<br />
|-<br />
| valign="top" | [[TWSocket.Proto | Proto]] |||| The protocol to use, can be '''tcp''' or '''tcp'''.<br />
|-<br />
| valign="top" | [[TWSocket.RcvdCnt | RcvdCnt]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.RcvdCount | RcvdCount]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.RcvdPtr | RcvdPtr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReadCount | ReadCount]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReqVerLow | ReqVerLow]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReqVerHigh | ReqVerHigh]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReuseAddr | ReuseAddr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SendFlags | SendFlags]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksAuthentication | SocksAuthentication]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksLevel | SocksLevel]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksPassword | SocksPassword]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksPort | SocksPort]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksServer | SocksServer]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksUsercode | SocksUsercode]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.State | State]] |||| Current state of the socket, mainly used for log or display purposes.<br />
|-<br />
| valign="top" | [[TWSocket.Terminated | Terminated]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Text | Text]] ||||<br />
|}<br />
<br />
== Methods ==<br />
<br />
{| <br />
| width="140" valign="top" | [[TWSocket.Abort | Abort]] |||| Close the socket, see also [[Closing a TCP session]].<br />
|-<br />
| valign="top" | [[TWSocket.Accept | Accept]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.CancelDnsLookup | CancelDnsLookup]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Close | Close]] |||| Close the socket gracefull, see also [[Closing a TCP session]].<br />
|-<br />
| valign="top" | [[TWSocket.CloseDelayed | CloseDelayed]] |||| Close the socket gracefull in a message handler, see also [[Closing a TCP session]].<br />
|-<br />
| valign="top" | [[TWSocket.Connect | Connect]] |||| Connect to a remote host.<br />
|-<br />
| valign="top" | [[TWSocket.Create | Create]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.DeleteBufferedData | DeleteBufferedData]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Destroy | Destroy]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.DnsLookup | DnsLookup]] |||| Perform a DNS lookup of a hostname in background. See also [[OnDNSLookupDone]].<br />
|-<br />
| valign="top" | [[TWSocket.Dup | Dup]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Flush | Flush]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetPeerAddr | GetPeerAddr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetPeerName | GetPeerName]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetPeerPort | GetPeerPort]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetSockName | GetSockName]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetXAddr | GetXAddr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetXPort | GetXPort]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Listen | Listen]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MessageLoop | MessageLoop]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MessagePump | MessagePump]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Pause | Pause]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.PeekData | PeekData]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ProcessMessage | ProcessMessage]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ProcessMessages | ProcessMessages]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.PutDataInSendBuffer | PutDataInSendBuffer]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.PutStringInSendBuffer | PutStringInSendBuffer]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Receive | Receive]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReceiveFrom | ReceiveFrom]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReceiveStr | ReceiveStr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Release | Release]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Resume | Resume]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReverseDnsLookup | ReverseDnsLookup]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Send | Send]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SendStr | SendStr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SendTo | SendTo]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SetLingerOption | SetLingerOption]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Shutdown | Shutdown]] |||| Close the socket gracefull, see also [[Closing a TCP session]].<br />
|-<br />
| valign="top" | [[TWSocket.TimerClear | TimerClear]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.TimerCmp | TimerCmp]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.TimerIsSet | TimerIsSet]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ThreadAttach | ThreadAttach]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ThreadDetach | ThreadDetach]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.WaitForClose | WaitForClose]] |||| Align test<br />
|}<br />
<br />
== Events ==<br />
<br />
{|<br />
| width="140" valign="top" | [[TWSocket.OnBgException | OnBgException]] |||| Background exception occured.<br />
|-<br />
| valign="top" | [[TWSocket.OnChangeState | OnChangeState]] |||| State of TWSocket has changed.<br />
|-<br />
| valign="top" | [[TWSocket.OnDataAvailable | OnDataAvailable]] |||| Data available in internal receive buffer.<br />
|-<br />
| valign="top" | [[TWSocket.OnDataSent | OnDataSent]] |||| Internal sent buffer is completely delivered to winsock.<br />
|-<br />
| width="90" valign="top" | [[TWSocket.OnDebugDisplay | OnDebugDisplay]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.OnDnsLookupDone | OnDnsLookupDone]] |||| [[TWSocket.DNSLookup | DNSLookup]] has finished.<br />
|-<br />
| valign="top" | [[TWSocket.OnError | OnError]] |||| '''Discouraged''', use exception handling instead.<br />
|-<br />
| valign="top" | [[TWSocket.OnLineLimitExceeded | OnLineLimitExceeded]] |||| Denial of service attack<br />
|-<br />
| valign="top" | [[TWSocket.OnMessagePump | OnMessagePump]] |||| To call your own message pump.<br />
|-<br />
| valign="top" | [[TWSocket.OnSendData | OnSendData]] |||| Winsock send buffer is empty, will be filled again by internal send buffer if still data available to send.<br />
|-<br />
| valign="top" | [[TWSocket.OnSessionAvailable | OnSessionAvailable]] |||| Client connected to this server.<br />
|-<br />
| valign="top" | [[TWSocket.OnSessionClosed | OnSessionClosed]] |||| Socket has closed.<br />
|-<br />
| valign="top" | [[TWSocket.OnSessionConnected | OnSessionConnected]] |||| Session to host etablished.<br />
|-<br />
| valign="top" | [[TWSocket.OnSocksAuthState | OnSocksAuthState]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.OnSocksConnected | OnSocksConnected]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.OnSocksError | OnSocksError]] ||||<br />
|}<br />
<br />
== How to ==<br />
<br />
[[TWSocket.HowTo.Title | Title]]<br />
<br />
{{Components_Footer}}</div>Wilfriedhttp://wiki.overbyte.eu/wiki/index.php?title=TWSocket&diff=1867TWSocket2006-02-25T16:39:42Z<p>Wilfried: /* Events */</p>
<hr />
<div>[[Main_Page | Main page]] -> [[ICS_Components_Reference | ICS component reference]] -> [[TWSocket]]<br />
== Overview ==<br />
<br />
*'''unit''' WSocket.pas<br />
*'''inheritance'''<br />
<br />
TWSocket component is implementing the TCP protocol described in RFC [http://rfc.net/rfc793.html 793] and and UDP protocol described in RFC [http://rfc.net/rfc768.html 768]. Both protocols are encaptulated by the IP protocol described in RFC [http://rfc.net/rfc791.html 791]. TWSocket is used in almost every other ICS component.<br />
<br />
TWSocket component can be used as client or a server. For its use as TCP server however [[TWSocketServer]] is encouraged because of his advanced features.<br />
<br />
== Properties ==<br />
<br />
{| <br />
| width="140" valign="top" | [[TWSocket.Addr | Addr]] |||| ''Client:'' The host to connect to. ''Server:'' The interface to listen on.<br />
|-<br />
| valign="top" | [[TWSocket.AllSent | AllSent]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.BufSize | BufSize]] |||| Size in bytes for send dynamic buffer cell.<br />
|-<br />
| valign="top" | [[TWSocket.ComponentOptions | ComponentOptions]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.DnsResult | DnsResult]] |||| Typically called in [[OnDnsLookupDone]]. The IP address of the remote host given as argument to [[DnsLookup]].<br />
|-<br />
| valign="top" | [[TWSocket.DnsResultList | DnsResultList]] |||| Similar to [[DnsResult]] but a TStringList containing the multiple IP's of the host if appropriate.<br />
|-<br />
| valign="top" | [[TWSocket.FlushTimeout | FlushTimeout]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Handle | Handle]] |||| Handle for the underlaying hidden window.<br />
|-<br />
| valign="top" | [[TWSocket.HSocket | HSocket]] |||| Winsock handle for underlaying socket.<br />
|-<br />
| valign="top" | [[TWSocket.IcsLogger | IcsLogger]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LastError | LastError]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LineEcho | LineEcho]] |||| Echo all received characters back to tramitter.<br />
|-<br />
| valign="top" | [[TWSocket.LineEdit | LineEdit]] |||| Handle received control characters used for editing.<br />
|-<br />
| valign="top" | [[TWSocket.LineEnd | LineEnd]] |||| End of line character(s) used ot trigger [[OnDataAvailable]].<br />
|-<br />
| valign="top" | [[TWSocket.LineLength | LineLength]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LineLimit | LineLimit]] |||| Maximum line lenght to receive before triggering [[OnLineLimitExceeded]]. See also [[DOS attac]].<br />
|-<br />
| valign="top" | [[TWSocket.LineMode | LineMode]] |||| Use [[LineEnd]] as end of line marker to trigger [[OnDataAvailable]].<br />
|-<br />
| valign="top" | [[TWSocket.LingerOnOff | LingerOnOff]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LingerTimeout | LingerTimeout]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ListenBacklog | ListenBacklog]] |||| <br />
|-<br />
| valign="top" | [[TWSocket.LocalAddr | LocalAddr]] |||| The local address where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.LocalPort | LocalPort]] |||| The local port where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.MultiCast | MultiCast]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MultiCastAddrStr | MultiCastAddrStr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MultiCastIpTTL | MultiCastIpTTL]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MultiThreaded | MultiThreaded]] |||| Set when TWSocket has to use his own message pump.<br />
|-<br />
| valign="top" | [[TWSocket.PeerAddr | PeerAddr]] |||| The remote address where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.PeerPort | PeerPort]] |||| The remote port port where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.Port | Port]] |||| ''Client:'' The port to connect to. ''Server:'' The port to listen on.<br />
|-<br />
| width="90" valign="top" | [[TWSocket.PortNum | PortNum]] |||| Integer value of [[Port]].<br />
|-<br />
| valign="top" | [[TWSocket.Proto | Proto]] |||| The protocol to use, can be '''tcp''' or '''tcp'''.<br />
|-<br />
| valign="top" | [[TWSocket.RcvdCnt | RcvdCnt]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.RcvdCount | RcvdCount]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.RcvdPtr | RcvdPtr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReadCount | ReadCount]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReqVerLow | ReqVerLow]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReqVerHigh | ReqVerHigh]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReuseAddr | ReuseAddr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SendFlags | SendFlags]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksAuthentication | SocksAuthentication]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksLevel | SocksLevel]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksPassword | SocksPassword]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksPort | SocksPort]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksServer | SocksServer]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksUsercode | SocksUsercode]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.State | State]] |||| Current state of the socket, mainly used for log or display purposes.<br />
|-<br />
| valign="top" | [[TWSocket.Terminated | Terminated]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Text | Text]] ||||<br />
|}<br />
<br />
== Methods ==<br />
<br />
{| <br />
| width="140" valign="top" | [[TWSocket.Abort | Abort]] |||| Close the socket, see also [[Closing a TCP session]].<br />
|-<br />
| valign="top" | [[TWSocket.Accept | Accept]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.CancelDnsLookup | CancelDnsLookup]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Close | Close]] |||| Close the socket gracefull, see also [[Closing a TCP session]].<br />
|-<br />
| valign="top" | [[TWSocket.CloseDelayed | CloseDelayed]] |||| Close the socket gracefull in a message handler, see also [[Closing a TCP session]].<br />
|-<br />
| valign="top" | [[TWSocket.Connect | Connect]] |||| Connect to a remote host.<br />
|-<br />
| valign="top" | [[TWSocket.Create | Create]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.DeleteBufferedData | DeleteBufferedData]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Destroy | Destroy]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.DnsLookup | DnsLookup]] |||| Perform a DNS lookup of a hostname in background. See also [[OnDNSLookupDone]].<br />
|-<br />
| valign="top" | [[TWSocket.Dup | Dup]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Flush | Flush]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetPeerAddr | GetPeerAddr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetPeerName | GetPeerName]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetPeerPort | GetPeerPort]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetSockName | GetSockName]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetXAddr | GetXAddr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetXPort | GetXPort]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Listen | Listen]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MessageLoop | MessageLoop]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MessagePump | MessagePump]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Pause | Pause]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.PeekData | PeekData]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ProcessMessage | ProcessMessage]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ProcessMessages | ProcessMessages]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.PutDataInSendBuffer | PutDataInSendBuffer]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.PutStringInSendBuffer | PutStringInSendBuffer]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Receive | Receive]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReceiveFrom | ReceiveFrom]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReceiveStr | ReceiveStr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Release | Release]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Resume | Resume]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReverseDnsLookup | ReverseDnsLookup]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Send | Send]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SendStr | SendStr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SendTo | SendTo]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SetLingerOption | SetLingerOption]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Shutdown | Shutdown]] |||| Close the socket gracefull, see also [[Closing a TCP session]].<br />
|-<br />
| valign="top" | [[TWSocket.TimerClear | TimerClear]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.TimerCmp | TimerCmp]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.TimerIsSet | TimerIsSet]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ThreadAttach | ThreadAttach]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ThreadDetach | ThreadDetach]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.WaitForClose | WaitForClose]] |||| Align test<br />
|}<br />
<br />
== Events ==<br />
<br />
{|<br />
| width="140" valign="top" | [[TWSocket.OnBgException | OnBgException]] |||| Background exception occured.<br />
|-<br />
| valign="top" | [[TWSocket.OnChangeState | OnChangeState]] |||| State of TWSocket has changed.<br />
|-<br />
| valign="top" | [[TWSocket.OnDataAvailable | OnDataAvailable]] |||| Data available in internal receive buffer.<br />
|-<br />
| valign="top" | [[TWSocket.OnDataSent | OnDataSent]] |||| Internal sent buffer is completely delivered to winsock.<br />
|-<br />
| width="90" valign="top" | [[TWSocket.OnDebugDisplay | OnDebugDisplay]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.OnDnsLookupDone | OnDnsLookupDone]] |||| [[TWSocket.DNSLookup | DNSLookup]] has finished.<br />
|-<br />
| valign="top" | [[TWSocket.OnError | OnError]] |||| '''Discouraged''', use exception handling instead.<br />
|-<br />
| valign="top" | [[TWSocket.OnLineLimitExceeded | OnLineLimitExceeded]] |||| Denial of service attack<br />
|-<br />
| valign="top" | [[TWSocket.OnMessagePump | OnMessagePump]] |||| To call your own message pump.<br />
|-<br />
| valign="top" | [[TWSocket.OnSendData | OnSendData]] |||| Winsock send buffer is empty, will be filled again by internal send buffer if still data available to send.<br />
|-<br />
| valign="top" | [[TWSocket.OnSessionAvailable | OnSessionAvailable]] |||| Client connected to this server.<br />
|-<br />
| valign="top" | [[TWSocket.OnSessionClosed | OnSessionClosed]] |||| Socket has closed.<br />
|-<br />
| valign="top" | [[TWSocket.OnSessionConnected | OnSessionConnected]] |||| Session to host etablished.<br />
|-<br />
| valign="top" | [[TWSocket.OnSocksAuthState | OnSocksAuthState]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.OnSocksConnected | OnSocksConnected]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.OnSocksError | OnSocksError]] ||||<br />
|}<br />
<br />
== How to ==<br />
<br />
[[TWSocket.HowTo.Title | Title]]<br />
<br />
{{Components_Footer}}</div>Wilfriedhttp://wiki.overbyte.eu/wiki/index.php?title=TWSocket&diff=1866TWSocket2006-02-25T16:38:15Z<p>Wilfried: /* Methods */</p>
<hr />
<div>[[Main_Page | Main page]] -> [[ICS_Components_Reference | ICS component reference]] -> [[TWSocket]]<br />
== Overview ==<br />
<br />
*'''unit''' WSocket.pas<br />
*'''inheritance'''<br />
<br />
TWSocket component is implementing the TCP protocol described in RFC [http://rfc.net/rfc793.html 793] and and UDP protocol described in RFC [http://rfc.net/rfc768.html 768]. Both protocols are encaptulated by the IP protocol described in RFC [http://rfc.net/rfc791.html 791]. TWSocket is used in almost every other ICS component.<br />
<br />
TWSocket component can be used as client or a server. For its use as TCP server however [[TWSocketServer]] is encouraged because of his advanced features.<br />
<br />
== Properties ==<br />
<br />
{| <br />
| width="140" valign="top" | [[TWSocket.Addr | Addr]] |||| ''Client:'' The host to connect to. ''Server:'' The interface to listen on.<br />
|-<br />
| valign="top" | [[TWSocket.AllSent | AllSent]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.BufSize | BufSize]] |||| Size in bytes for send dynamic buffer cell.<br />
|-<br />
| valign="top" | [[TWSocket.ComponentOptions | ComponentOptions]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.DnsResult | DnsResult]] |||| Typically called in [[OnDnsLookupDone]]. The IP address of the remote host given as argument to [[DnsLookup]].<br />
|-<br />
| valign="top" | [[TWSocket.DnsResultList | DnsResultList]] |||| Similar to [[DnsResult]] but a TStringList containing the multiple IP's of the host if appropriate.<br />
|-<br />
| valign="top" | [[TWSocket.FlushTimeout | FlushTimeout]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Handle | Handle]] |||| Handle for the underlaying hidden window.<br />
|-<br />
| valign="top" | [[TWSocket.HSocket | HSocket]] |||| Winsock handle for underlaying socket.<br />
|-<br />
| valign="top" | [[TWSocket.IcsLogger | IcsLogger]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LastError | LastError]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LineEcho | LineEcho]] |||| Echo all received characters back to tramitter.<br />
|-<br />
| valign="top" | [[TWSocket.LineEdit | LineEdit]] |||| Handle received control characters used for editing.<br />
|-<br />
| valign="top" | [[TWSocket.LineEnd | LineEnd]] |||| End of line character(s) used ot trigger [[OnDataAvailable]].<br />
|-<br />
| valign="top" | [[TWSocket.LineLength | LineLength]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LineLimit | LineLimit]] |||| Maximum line lenght to receive before triggering [[OnLineLimitExceeded]]. See also [[DOS attac]].<br />
|-<br />
| valign="top" | [[TWSocket.LineMode | LineMode]] |||| Use [[LineEnd]] as end of line marker to trigger [[OnDataAvailable]].<br />
|-<br />
| valign="top" | [[TWSocket.LingerOnOff | LingerOnOff]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LingerTimeout | LingerTimeout]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ListenBacklog | ListenBacklog]] |||| <br />
|-<br />
| valign="top" | [[TWSocket.LocalAddr | LocalAddr]] |||| The local address where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.LocalPort | LocalPort]] |||| The local port where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.MultiCast | MultiCast]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MultiCastAddrStr | MultiCastAddrStr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MultiCastIpTTL | MultiCastIpTTL]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MultiThreaded | MultiThreaded]] |||| Set when TWSocket has to use his own message pump.<br />
|-<br />
| valign="top" | [[TWSocket.PeerAddr | PeerAddr]] |||| The remote address where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.PeerPort | PeerPort]] |||| The remote port port where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.Port | Port]] |||| ''Client:'' The port to connect to. ''Server:'' The port to listen on.<br />
|-<br />
| width="90" valign="top" | [[TWSocket.PortNum | PortNum]] |||| Integer value of [[Port]].<br />
|-<br />
| valign="top" | [[TWSocket.Proto | Proto]] |||| The protocol to use, can be '''tcp''' or '''tcp'''.<br />
|-<br />
| valign="top" | [[TWSocket.RcvdCnt | RcvdCnt]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.RcvdCount | RcvdCount]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.RcvdPtr | RcvdPtr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReadCount | ReadCount]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReqVerLow | ReqVerLow]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReqVerHigh | ReqVerHigh]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReuseAddr | ReuseAddr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SendFlags | SendFlags]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksAuthentication | SocksAuthentication]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksLevel | SocksLevel]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksPassword | SocksPassword]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksPort | SocksPort]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksServer | SocksServer]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksUsercode | SocksUsercode]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.State | State]] |||| Current state of the socket, mainly used for log or display purposes.<br />
|-<br />
| valign="top" | [[TWSocket.Terminated | Terminated]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Text | Text]] ||||<br />
|}<br />
<br />
== Methods ==<br />
<br />
{| <br />
| width="140" valign="top" | [[TWSocket.Abort | Abort]] |||| Close the socket, see also [[Closing a TCP session]].<br />
|-<br />
| valign="top" | [[TWSocket.Accept | Accept]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.CancelDnsLookup | CancelDnsLookup]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Close | Close]] |||| Close the socket gracefull, see also [[Closing a TCP session]].<br />
|-<br />
| valign="top" | [[TWSocket.CloseDelayed | CloseDelayed]] |||| Close the socket gracefull in a message handler, see also [[Closing a TCP session]].<br />
|-<br />
| valign="top" | [[TWSocket.Connect | Connect]] |||| Connect to a remote host.<br />
|-<br />
| valign="top" | [[TWSocket.Create | Create]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.DeleteBufferedData | DeleteBufferedData]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Destroy | Destroy]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.DnsLookup | DnsLookup]] |||| Perform a DNS lookup of a hostname in background. See also [[OnDNSLookupDone]].<br />
|-<br />
| valign="top" | [[TWSocket.Dup | Dup]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Flush | Flush]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetPeerAddr | GetPeerAddr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetPeerName | GetPeerName]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetPeerPort | GetPeerPort]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetSockName | GetSockName]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetXAddr | GetXAddr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetXPort | GetXPort]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Listen | Listen]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MessageLoop | MessageLoop]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MessagePump | MessagePump]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Pause | Pause]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.PeekData | PeekData]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ProcessMessage | ProcessMessage]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ProcessMessages | ProcessMessages]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.PutDataInSendBuffer | PutDataInSendBuffer]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.PutStringInSendBuffer | PutStringInSendBuffer]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Receive | Receive]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReceiveFrom | ReceiveFrom]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReceiveStr | ReceiveStr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Release | Release]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Resume | Resume]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReverseDnsLookup | ReverseDnsLookup]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Send | Send]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SendStr | SendStr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SendTo | SendTo]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SetLingerOption | SetLingerOption]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Shutdown | Shutdown]] |||| Close the socket gracefull, see also [[Closing a TCP session]].<br />
|-<br />
| valign="top" | [[TWSocket.TimerClear | TimerClear]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.TimerCmp | TimerCmp]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.TimerIsSet | TimerIsSet]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ThreadAttach | ThreadAttach]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ThreadDetach | ThreadDetach]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.WaitForClose | WaitForClose]] |||| Align test<br />
|}<br />
<br />
== Events ==<br />
<br />
{|<br />
| width="140" valign="top" | [[TWSocket.OnBgException | OnBgException]] |||| Background exception occured.<br />
|-<br />
| valign="top" | [[TWSocket.OnChangeState | OnChangeState]] |||| State of TWSocket has changed.<br />
|-<br />
| valign="top" | [[TWSocket.OnDataAvailable | OnDataAvailable]] |||| Data available in internal receive buffer.<br />
|-<br />
| valign="top" | [[TWSocket.OnDataSent | OnDataSent]] |||| Internal sent buffer is completely delivered to winsock.<br />
|-<br />
| width="90" valign="top" | [[TWSocket.OnDebugDisplay | OnDebugDisplay]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.OnDnsLookupDone | OnDnsLookupDone]] |||| [[TWSocket.DNSLookUp | DNSLookUp]] has finished.<br />
|-<br />
| valign="top" | [[TWSocket.OnError | OnError]] |||| '''Discouraged''', use exception handling instead.<br />
|-<br />
| valign="top" | [[TWSocket.OnLineLimitExceeded | OnLineLimitExceeded]] |||| Denial of service attack<br />
|-<br />
| valign="top" | [[TWSocket.OnMessagePump | OnMessagePump]] |||| To call your own message pump.<br />
|-<br />
| valign="top" | [[TWSocket.OnSendData | OnSendData]] |||| Winsock send buffer is empty, will be filled again by internal send buffer if still data available to send.<br />
|-<br />
| valign="top" | [[TWSocket.OnSessionAvailable | OnSessionAvailable]] |||| Client connected to this server.<br />
|-<br />
| valign="top" | [[TWSocket.OnSessionClosed | OnSessionClosed]] |||| Socket has closed.<br />
|-<br />
| valign="top" | [[TWSocket.OnSessionConnected | OnSessionConnected]] |||| Session to host etablished.<br />
|-<br />
| valign="top" | [[TWSocket.OnSocksAuthState | OnSocksAuthState]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.OnSocksConnected | OnSocksConnected]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.OnSocksError | OnSocksError]] ||||<br />
|}<br />
<br />
== How to ==<br />
<br />
[[TWSocket.HowTo.Title | Title]]<br />
<br />
{{Components_Footer}}</div>Wilfriedhttp://wiki.overbyte.eu/wiki/index.php?title=TWSocket&diff=1865TWSocket2006-02-25T16:37:14Z<p>Wilfried: /* Methods */</p>
<hr />
<div>[[Main_Page | Main page]] -> [[ICS_Components_Reference | ICS component reference]] -> [[TWSocket]]<br />
== Overview ==<br />
<br />
*'''unit''' WSocket.pas<br />
*'''inheritance'''<br />
<br />
TWSocket component is implementing the TCP protocol described in RFC [http://rfc.net/rfc793.html 793] and and UDP protocol described in RFC [http://rfc.net/rfc768.html 768]. Both protocols are encaptulated by the IP protocol described in RFC [http://rfc.net/rfc791.html 791]. TWSocket is used in almost every other ICS component.<br />
<br />
TWSocket component can be used as client or a server. For its use as TCP server however [[TWSocketServer]] is encouraged because of his advanced features.<br />
<br />
== Properties ==<br />
<br />
{| <br />
| width="140" valign="top" | [[TWSocket.Addr | Addr]] |||| ''Client:'' The host to connect to. ''Server:'' The interface to listen on.<br />
|-<br />
| valign="top" | [[TWSocket.AllSent | AllSent]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.BufSize | BufSize]] |||| Size in bytes for send dynamic buffer cell.<br />
|-<br />
| valign="top" | [[TWSocket.ComponentOptions | ComponentOptions]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.DnsResult | DnsResult]] |||| Typically called in [[OnDnsLookupDone]]. The IP address of the remote host given as argument to [[DnsLookup]].<br />
|-<br />
| valign="top" | [[TWSocket.DnsResultList | DnsResultList]] |||| Similar to [[DnsResult]] but a TStringList containing the multiple IP's of the host if appropriate.<br />
|-<br />
| valign="top" | [[TWSocket.FlushTimeout | FlushTimeout]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Handle | Handle]] |||| Handle for the underlaying hidden window.<br />
|-<br />
| valign="top" | [[TWSocket.HSocket | HSocket]] |||| Winsock handle for underlaying socket.<br />
|-<br />
| valign="top" | [[TWSocket.IcsLogger | IcsLogger]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LastError | LastError]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LineEcho | LineEcho]] |||| Echo all received characters back to tramitter.<br />
|-<br />
| valign="top" | [[TWSocket.LineEdit | LineEdit]] |||| Handle received control characters used for editing.<br />
|-<br />
| valign="top" | [[TWSocket.LineEnd | LineEnd]] |||| End of line character(s) used ot trigger [[OnDataAvailable]].<br />
|-<br />
| valign="top" | [[TWSocket.LineLength | LineLength]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LineLimit | LineLimit]] |||| Maximum line lenght to receive before triggering [[OnLineLimitExceeded]]. See also [[DOS attac]].<br />
|-<br />
| valign="top" | [[TWSocket.LineMode | LineMode]] |||| Use [[LineEnd]] as end of line marker to trigger [[OnDataAvailable]].<br />
|-<br />
| valign="top" | [[TWSocket.LingerOnOff | LingerOnOff]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.LingerTimeout | LingerTimeout]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ListenBacklog | ListenBacklog]] |||| <br />
|-<br />
| valign="top" | [[TWSocket.LocalAddr | LocalAddr]] |||| The local address where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.LocalPort | LocalPort]] |||| The local port where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.MultiCast | MultiCast]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MultiCastAddrStr | MultiCastAddrStr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MultiCastIpTTL | MultiCastIpTTL]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MultiThreaded | MultiThreaded]] |||| Set when TWSocket has to use his own message pump.<br />
|-<br />
| valign="top" | [[TWSocket.PeerAddr | PeerAddr]] |||| The remote address where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.PeerPort | PeerPort]] |||| The remote port port where the socket is bound to.<br />
|-<br />
| valign="top" | [[TWSocket.Port | Port]] |||| ''Client:'' The port to connect to. ''Server:'' The port to listen on.<br />
|-<br />
| width="90" valign="top" | [[TWSocket.PortNum | PortNum]] |||| Integer value of [[Port]].<br />
|-<br />
| valign="top" | [[TWSocket.Proto | Proto]] |||| The protocol to use, can be '''tcp''' or '''tcp'''.<br />
|-<br />
| valign="top" | [[TWSocket.RcvdCnt | RcvdCnt]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.RcvdCount | RcvdCount]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.RcvdPtr | RcvdPtr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReadCount | ReadCount]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReqVerLow | ReqVerLow]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReqVerHigh | ReqVerHigh]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReuseAddr | ReuseAddr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SendFlags | SendFlags]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksAuthentication | SocksAuthentication]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksLevel | SocksLevel]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksPassword | SocksPassword]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksPort | SocksPort]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksServer | SocksServer]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SocksUsercode | SocksUsercode]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.State | State]] |||| Current state of the socket, mainly used for log or display purposes.<br />
|-<br />
| valign="top" | [[TWSocket.Terminated | Terminated]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Text | Text]] ||||<br />
|}<br />
<br />
== Methods ==<br />
<br />
{| <br />
| width="140" valign="top" | [[TWSocket.Abort | Abort]] |||| Close the socket, see also [[Closing a socket]].<br />
|-<br />
| valign="top" | [[TWSocket.Accept | Accept]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.CancelDnsLookup | CancelDnsLookup]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Close | Close]] |||| Close the socket gracefull, see also [[Closing a socket]].<br />
|-<br />
| valign="top" | [[TWSocket.CloseDelayed | CloseDelayed]] |||| Close the socket gracefull in a message handler, see also [[Closing a socket]].<br />
|-<br />
| valign="top" | [[TWSocket.Connect | Connect]] |||| Connect to a remote host.<br />
|-<br />
| valign="top" | [[TWSocket.Create | Create]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.DeleteBufferedData | DeleteBufferedData]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Destroy | Destroy]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.DnsLookup | DnsLookup]] |||| Perform a DNS lookup of a hostname in background. See also [[OnDNSLookupDone]].<br />
|-<br />
| valign="top" | [[TWSocket.Dup | Dup]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Flush | Flush]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetPeerAddr | GetPeerAddr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetPeerName | GetPeerName]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetPeerPort | GetPeerPort]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetSockName | GetSockName]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetXAddr | GetXAddr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.GetXPort | GetXPort]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Listen | Listen]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MessageLoop | MessageLoop]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.MessagePump | MessagePump]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Pause | Pause]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.PeekData | PeekData]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ProcessMessage | ProcessMessage]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ProcessMessages | ProcessMessages]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.PutDataInSendBuffer | PutDataInSendBuffer]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.PutStringInSendBuffer | PutStringInSendBuffer]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Receive | Receive]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReceiveFrom | ReceiveFrom]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReceiveStr | ReceiveStr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Release | Release]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Resume | Resume]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ReverseDnsLookup | ReverseDnsLookup]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Send | Send]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SendStr | SendStr]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SendTo | SendTo]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.SetLingerOption | SetLingerOption]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.Shutdown | Shutdown]] |||| Close the socket gracefull, see also [[Closing a socket]].<br />
|-<br />
| valign="top" | [[TWSocket.TimerClear | TimerClear]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.TimerCmp | TimerCmp]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.TimerIsSet | TimerIsSet]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ThreadAttach | ThreadAttach]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.ThreadDetach | ThreadDetach]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.WaitForClose | WaitForClose]] |||| Align test<br />
|}<br />
<br />
== Events ==<br />
<br />
{|<br />
| width="140" valign="top" | [[TWSocket.OnBgException | OnBgException]] |||| Background exception occured.<br />
|-<br />
| valign="top" | [[TWSocket.OnChangeState | OnChangeState]] |||| State of TWSocket has changed.<br />
|-<br />
| valign="top" | [[TWSocket.OnDataAvailable | OnDataAvailable]] |||| Data available in internal receive buffer.<br />
|-<br />
| valign="top" | [[TWSocket.OnDataSent | OnDataSent]] |||| Internal sent buffer is completely delivered to winsock.<br />
|-<br />
| width="90" valign="top" | [[TWSocket.OnDebugDisplay | OnDebugDisplay]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.OnDnsLookupDone | OnDnsLookupDone]] |||| [[TWSocket.DNSLookUp | DNSLookUp]] has finished.<br />
|-<br />
| valign="top" | [[TWSocket.OnError | OnError]] |||| '''Discouraged''', use exception handling instead.<br />
|-<br />
| valign="top" | [[TWSocket.OnLineLimitExceeded | OnLineLimitExceeded]] |||| Denial of service attack<br />
|-<br />
| valign="top" | [[TWSocket.OnMessagePump | OnMessagePump]] |||| To call your own message pump.<br />
|-<br />
| valign="top" | [[TWSocket.OnSendData | OnSendData]] |||| Winsock send buffer is empty, will be filled again by internal send buffer if still data available to send.<br />
|-<br />
| valign="top" | [[TWSocket.OnSessionAvailable | OnSessionAvailable]] |||| Client connected to this server.<br />
|-<br />
| valign="top" | [[TWSocket.OnSessionClosed | OnSessionClosed]] |||| Socket has closed.<br />
|-<br />
| valign="top" | [[TWSocket.OnSessionConnected | OnSessionConnected]] |||| Session to host etablished.<br />
|-<br />
| valign="top" | [[TWSocket.OnSocksAuthState | OnSocksAuthState]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.OnSocksConnected | OnSocksConnected]] ||||<br />
|-<br />
| valign="top" | [[TWSocket.OnSocksError | OnSocksError]] ||||<br />
|}<br />
<br />
== How to ==<br />
<br />
[[TWSocket.HowTo.Title | Title]]<br />
<br />
{{Components_Footer}}</div>Wilfried