Difference between revisions of "TWSocket"

From Overbyte
Jump to navigation Jump to search
 
(25 intermediate revisions by 6 users not shown)
Line 3: Line 3:
  
 
{|
 
{|
| '''unit'''        |||| WSocket.pas
+
| '''unit'''        || [[OverbyteIcsWSocket.pas|OverbyteIcsWSocket.pas]]
 
|-
 
|-
| '''inheritance''' ||||
+
| style="vertical-align:top;"| '''inheritance''' || TCustomThrottledWSocket (optional) -> TCustomTimeoutWSocket (optional) -> TCustomSyncWSocket -> TCustomLineWSocket -> TCustomSslWSocket (optional) -> TCustomSocksWSocket -> TCustomSocksWSocket -> TCustomHttpTunnelWSocket -> TCustomWSocket -> TIcsWndControl  (*Optional = Depending on preprocessors)
 
|}
 
|}
  
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.
+
TWSocket component is implementing the TCP protocol described in RFC [http://rfc.net/rfc793.html 793] and the UDP protocol described in RFC [http://rfc.net/rfc768.html 768]. TWSocket is used in almost every other ICS component.
  
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.
+
TWSocket component can be used as [[Glossary#Client | client]] as well as a [[Glossary#Server | Server]] socket (listening). For use as a TCP server however [[TWSocketServer]] is encouraged because it provides advanced features.
  
 
== Properties ==
 
== Properties ==
Line 17: Line 17:
 
| width="140" valign="top" | [[TWSocket.Addr | Addr]] |||| ''Client:'' The host to connect to. ''Server:'' The interface to listen on.
 
| width="140" valign="top" | [[TWSocket.Addr | Addr]] |||| ''Client:'' The host to connect to. ''Server:'' The interface to listen on.
 
|-
 
|-
| valign="top" | [[TWSocket.AllSent | AllSent]] ||||
+
| valign="top" | [[TWSocket.AllSent | AllSent]] |||| Boolean indicating if all data in internal buffer has been sent.
 
|-
 
|-
| valign="top" | [[TWSocket.BufSize | BufSize]] |||| Size in bytes for dynamic send buffer cells.
+
| valign="top" | [[TWSocket.BufSize | BufSize]] |||| Size in bytes for dynamic send buffer calls.
 
|-
 
|-
| valign="top" | [[TWSocket.ComponentOptions | ComponentOptions]] |||| Used to modify how the component handle some operations.
+
| valign="top" | [[TWSocket.ComponentOptions | ComponentOptions]] |||| Used to modify how the component handles some operations.
 
|-
 
|-
| 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]].
+
| valign="top" | [[TWSocket.DnsResult | DnsResult]] |||| Typically called in [[TWSocket.OnDnsLookupDone | OnDnsLookupDone]]. The IP address of the remote host given as an argument to [[TWSocket.DnsLookup | DnsLookup]].
 
|-
 
|-
| valign="top" | [[TWSocket.DnsResultList | DnsResultList]] |||| Similar to [[TWSocket.DnsResult | DnsResult]] but a TStringList containing the multiple IP's of the host if appropriate.
+
| valign="top" | [[TWSocket.DnsResultList | DnsResultList]] |||| Similar to [[TWSocket.DnsResult | DnsResult]] but a TStringList containing the multiple IPs of the host, if appropriate.
 
|-
 
|-
| valign="top" | [[TWSocket.Handle | Handle]] |||| Handle for the underlaying hidden window.
+
| valign="top" | [[TWSocket.Handle | Handle]] |||| Handle for the underlying hidden window.
 
|-
 
|-
| valign="top" | [[TWSocket.HSocket | HSocket]] |||| Winsock handle for underlaying socket.
+
| valign="top" | [[TWSocket.HSocket | HSocket]] |||| Winsock handle for underlying socket.
 
|-
 
|-
| valign="top" | [[TWSocket.IcsLogger | IcsLogger]] ||||
+
| valign="top" | [[TWSocket.IcsLogger | IcsLogger]] |||| Linked component to log debug messages.
 
|-
 
|-
| valign="top" | [[TWSocket.LastError | LastError]] |||| Save the last error occured during socket operation.
+
| valign="top" | [[TWSocket.LastError | LastError]] |||| The last error occurred during socket operation.
 
|-
 
|-
| valign="top" | [[TWSocket.LineEcho | LineEcho]] |||| Echo all received characters back to tramitter.
+
| valign="top" | [[TWSocket.LineEcho | LineEcho]] |||| Echo all received characters back to transmitter.
 
|-
 
|-
 
| valign="top" | [[TWSocket.LineEdit | LineEdit]] |||| Handle received control characters used for editing.
 
| valign="top" | [[TWSocket.LineEdit | LineEdit]] |||| Handle received control characters used for editing.
 
|-
 
|-
| valign="top" | [[TWSocket.LineEnd | LineEnd]] |||| End of line character(s) used ot trigger [[TWSocket.OnDataAvailable | OnDataAvailable]].
+
| valign="top" | [[TWSocket.LineEnd | LineEnd]] |||| End of line character(s) used to trigger [[TWSocket.OnDataAvailable | OnDataAvailable]].
 
|-
 
|-
 
| valign="top" | [[TWSocket.LineLength | LineLength]] |||| When using LineMode: the length of the received line.
 
| valign="top" | [[TWSocket.LineLength | LineLength]] |||| When using LineMode: the length of the received line.
 
|-
 
|-
| valign="top" | [[TWSocket.LineLimit | LineLimit]] |||| Maximum line lenght to receive before triggering [[TWSocket.OnLineLimitExceeded | OnLineLimitExceeded]]. See also [[DOS attac]].
+
| valign="top" | [[TWSocket.LineLimit | LineLimit]] |||| Maximum line length to receive before triggering [[TWSocket.OnLineLimitExceeded | OnLineLimitExceeded]]. See also [[DOS attack]].
 
|-
 
|-
 
| valign="top" | [[TWSocket.LineMode | LineMode]] |||| Use [[TWSocket.LineEnd | LineEnd]] as end of line marker to trigger [[TWSocket.OnDataAvailable | OnDataAvailable]].
 
| valign="top" | [[TWSocket.LineMode | LineMode]] |||| Use [[TWSocket.LineEnd | LineEnd]] as end of line marker to trigger [[TWSocket.OnDataAvailable | OnDataAvailable]].
 
|-
 
|-
| valign="top" | [[TWSocket.LingerOnOff | LingerOnOff]] ||||
+
| valign="top" | [[TWSocket.LingerOnOff | LingerOnOff]] |||| Select linger mode.
 
|-
 
|-
| valign="top" | [[TWSocket.LingerTimeout | LingerTimeout]] ||||
+
| valign="top" | [[TWSocket.LingerTimeout | LingerTimeout]] |||| Select linger timeout.
 
|-
 
|-
 
| valign="top" | [[TWSocket.ListenBacklog | ListenBacklog]] |||| Size of pending connection queue in server mode.
 
| valign="top" | [[TWSocket.ListenBacklog | ListenBacklog]] |||| Size of pending connection queue in server mode.
 
|-
 
|-
| valign="top" | [[TWSocket.LocalAddr | LocalAddr]] |||| The local address where the socket is bound to.
+
| valign="top" | [[TWSocket.LocalAddr | LocalAddr]] |||| The local address to which the socket is bound.
 
|-
 
|-
| valign="top" | [[TWSocket.LocalPort | LocalPort]] |||| The local port where the socket is bound to.
+
| valign="top" | [[TWSocket.LocalPort | LocalPort]] |||| The local port to which the socket is bound.
 
|-
 
|-
| valign="top" | [[TWSocket.MultiCast | MultiCast]] ||||
+
| valign="top" | [[TWSocket.MultiCast | MultiCast]] |||| Select multicast.
 
|-
 
|-
| valign="top" | [[TWSocket.MultiCastAddrStr | MultiCastAddrStr]] ||||
+
| valign="top" | [[TWSocket.MultiCastAddrStr | MultiCastAddrStr]] |||| Select multicast address.
 
|-
 
|-
| valign="top" | [[TWSocket.MultiCastIpTTL | MultiCastIpTTL]] ||||
+
| valign="top" | [[TWSocket.MultiCastIpTTL | MultiCastIpTTL]] |||| Select multicast "Time to Live".
 
|-
 
|-
| valign="top" | [[TWSocket.MultiThreaded | MultiThreaded]] |||| Set when TWSocket has to use his own message pump.
+
| valign="top" | [[TWSocket.MultiThreaded | MultiThreaded]] |||| Set when TWSocket must use its own message pump.
 
|-
 
|-
| valign="top" | [[TWSocket.PeerAddr | PeerAddr]] |||| The remote address where the socket is bound to.
+
| valign="top" | [[TWSocket.PeerAddr | PeerAddr]] |||| The remote address to which the socket is bound.
 
|-
 
|-
| valign="top" | [[TWSocket.PeerPort | PeerPort]] |||| The remote port port where the socket is bound to.
+
| valign="top" | [[TWSocket.PeerPort | PeerPort]] |||| The remote port to which the socket is bound.
 
|-
 
|-
 
| valign="top" | [[TWSocket.Port | Port]] |||| ''Client:'' The port to connect to. ''Server:'' The port to listen on.
 
| valign="top" | [[TWSocket.Port | Port]] |||| ''Client:'' The port to connect to. ''Server:'' The port to listen on.
Line 73: Line 73:
 
| width="90" valign="top" | [[TWSocket.PortNum | PortNum]] |||| Integer value of [[TWSocket.Port | Port]].
 
| width="90" valign="top" | [[TWSocket.PortNum | PortNum]] |||| Integer value of [[TWSocket.Port | Port]].
 
|-
 
|-
| valign="top" | [[TWSocket.Proto | Proto]] |||| The protocol to use, can be '''tcp''' or '''tcp'''.
+
| valign="top" | [[TWSocket.Proto | Proto]] |||| The protocol to use, can be '''tcp''', '''udp''' or '''raw'''.
 
|-
 
|-
| valign="top" | [[TWSocket.RcvdCnt | RcvdCnt]] |||| Number of character received in internal buffer when using line mode.
+
| valign="top" | [[TWSocket.RcvdCnt | RcvdCnt]] |||| Number of characters received in internal buffer when using line mode.
 
|-
 
|-
| valign="top" | [[TWSocket.RcvdCount | RcvdCount]] |||| Number of characters in receive buffer but not read yet.
+
| valign="top" | [[TWSocket.RcvdCount | RcvdCount]] |||| Number of characters in receive buffer but, not read.
 
|-
 
|-
| valign="top" | [[TWSocket.RcvdPtr | RcvdPtr]] |||| Internal rceive buffer pointer used for line mode.
+
| valign="top" | [[TWSocket.RcvdPtr | RcvdPtr]] |||| Internal receive buffer pointer used for line mode.
 
|-
 
|-
 
| valign="top" | [[TWSocket.ReadCount | ReadCount]] |||| Total number of bytes received.
 
| valign="top" | [[TWSocket.ReadCount | ReadCount]] |||| Total number of bytes received.
Line 91: Line 91:
 
| valign="top" | [[TWSocket.SendFlags | SendFlags]] |||| How to send data.
 
| valign="top" | [[TWSocket.SendFlags | SendFlags]] |||| How to send data.
 
|-
 
|-
| valign="top" | [[TWSocket.SocksAuthentication | SocksAuthentication]] ||||
+
| valign="top" | [[TWSocket.SocketErrs | SocketErrs ]] ||||How socket error messages should be presented as type TSocketErrs, wsErrTech or wsErrFriendly.
 
|-
 
|-
| valign="top" | [[TWSocket.SocksLevel | SocksLevel]] ||||
+
| valign="top" | [[TWSocket.SocketFamily |SocketFamily ]] |||| SocketFamily determines whether connections can use IPv4, IPv6 addresses or both, if both are available.
 
|-
 
|-
| valign="top" | [[TWSocket.SocksPassword | SocksPassword]] ||||
+
| valign="top" | [[TWSocket.SocksAuthentication | SocksAuthentication]] |||| Select socks server authentication mode.
 +
|-
 +
| valign="top" | [[TWSocket.SocksLevel | SocksLevel]] |||| Select socks server protocol level.
 +
|-
 +
| valign="top" | [[TWSocket.SocksPassword | SocksPassword]] |||| Password for socks server authentication.
 
|-
 
|-
 
| valign="top" | [[TWSocket.SocksPort | SocksPort]] |||| Port number for socks server.
 
| valign="top" | [[TWSocket.SocksPort | SocksPort]] |||| Port number for socks server.
Line 103: Line 107:
 
| valign="top" | [[TWSocket.SocksUsercode | SocksUsercode]] |||| Usercode for socks server authentication.
 
| valign="top" | [[TWSocket.SocksUsercode | SocksUsercode]] |||| Usercode for socks server authentication.
 
|-
 
|-
| valign="top" | [[TWSocket.State | State]] |||| Current state of the socket, mainly used for log or display purposes.
+
| valign="top" | [[TWSocket.State | State]] |||| Current state of the socket; mainly used for log or display purposes.
 
|-
 
|-
| valign="top" | [[TWSocket.Terminated | Terminated]] |||| To be set to terminate synchronous operation prematurely.
+
| valign="top" | [[TWSocket.Terminated | Terminated]] |||| Set to terminate synchronous operation prematurely.
 
|-
 
|-
 
| valign="top" | [[TWSocket.Text | Text]] |||| Equivalent to ReceiveStr and SendStr.
 
| valign="top" | [[TWSocket.Text | Text]] |||| Equivalent to ReceiveStr and SendStr.
Line 115: Line 119:
 
| width="140" valign="top" | [[TWSocket.Abort | Abort]] |||| Quick and dirty way to close the socket.
 
| width="140" valign="top" | [[TWSocket.Abort | Abort]] |||| Quick and dirty way to close the socket.
 
|-
 
|-
| valign="top" | [[TWSocket.Accept | Accept]] ||||
+
| valign="top" | [[TWSocket.Accept | Accept]] |||| Accept a new incomming connection request.
 
|-
 
|-
| valign="top" | [[TWSocket.CancelDnsLookup | CancelDnsLookup]] ||||
+
| valign="top" | [[TWSocket.CancelDnsLookup | CancelDnsLookup]] |||| Cancel any pending DNS lookup.
 
|-
 
|-
| valign="top" | [[TWSocket.Close | Close]] |||| Close the socket gracefull.
+
| valign="top" | [[TWSocket.Close | Close]] |||| Close the socket gracefully.
 
|-
 
|-
| valign="top" | [[TWSocket.CloseDelayed | CloseDelayed]] |||| Close the socket gracefull in a message handler.
+
| valign="top" | [[TWSocket.CloseDelayed | CloseDelayed]] |||| Close the socket when the current event terminates.
 
|-
 
|-
 
| valign="top" | [[TWSocket.Connect | Connect]] |||| Connect to a remote host.
 
| valign="top" | [[TWSocket.Connect | Connect]] |||| Connect to a remote host.
 
|-
 
|-
| valign="top" | [[TWSocket.Create | Create]] |||| Dynamcly create the component.
+
| valign="top" | [[TWSocket.Create | Create]] |||| Dynamically create the component.
 
|-
 
|-
| valign="top" | [[TWSocket.DeleteBufferedData | DeleteBufferedData]] ||||
+
| valign="top" | [[TWSocket.DeleteBufferedData | DeleteBufferedData]] |||| Delete internal buffered data.
 
|-
 
|-
| valign="top" | [[TWSocket.Destroy | Destroy]] |||| Destroy the dynamicly created component.
+
| valign="top" | [[TWSocket.Destroy | Destroy]] |||| Destroy the dynamically created component.
 
|-
 
|-
 
| valign="top" | [[TWSocket.DnsLookup | DnsLookup]] |||| Perform a DNS lookup of a hostname in background. See also [[TWSocket.OnDNSLookupDone | OnDNSLookupDone]].
 
| valign="top" | [[TWSocket.DnsLookup | DnsLookup]] |||| Perform a DNS lookup of a hostname in background. See also [[TWSocket.OnDNSLookupDone | OnDNSLookupDone]].
 
|-
 
|-
| valign="top" | [[TWSocket.Dup | Dup]] ||||
+
| valign="top" | [[TWSocket.Dup | Dup]] |||| Assign a socket handle to the component.
 
|-
 
|-
| valign="top" | [[TWSocket.Flush | Flush]] ||||
+
| valign="top" | [[TWSocket.Flush | Flush]] |||| Wait until the internal buffer is flushed. Better avoid this method.
 
|-
 
|-
| valign="top" | [[TWSocket.GetPeerAddr | GetPeerAddr]] |||| Returns the remote address where the socket has been bound. See also [[TWSocket.PeerAddr | PeerAddr]].
+
| valign="top" | [[TWSocket.GetPeerAddr | GetPeerAddr]] |||| Returns the remote address the socket is bound. See also [[TWSocket.PeerAddr | PeerAddr]].
 
|-
 
|-
| valign="top" | [[TWSocket.GetPeerName | GetPeerName]] |||| Returns the remot hostname where the socket has been bound.
+
| valign="top" | [[TWSocket.GetPeerName | GetPeerName]] |||| Returns the remote hostname the socket is bound.
 
|-
 
|-
| valign="top" | [[TWSocket.GetPeerPort | GetPeerPort]] |||| Returns the remote port where the socket has been bound. See also [[TWSocket.PeerPort | PeerPort]].
+
| valign="top" | [[TWSocket.GetPeerPort | GetPeerPort]] |||| Returns the remote port the socket has is bound. See also [[TWSocket.PeerPort | PeerPort]].
 
|-
 
|-
| valign="top" | [[TWSocket.GetSockName | GetSockName]] ||||
+
| valign="top" | [[TWSocket.GetSockName | GetSockName]] |||| Returns socket binding information.
 
|-
 
|-
| valign="top" | [[TWSocket.GetXAddr | GetXAddr]] |||| Returns the local interface to where the socket has been bound.
+
| valign="top" | [[TWSocket.GetXAddr | GetXAddr]] |||| Returns the local interface the socket is bound.
 
|-
 
|-
| valign="top" | [[TWSocket.GetXPort | GetXPort]] |||| Returns the local port to where the socket has been bound.
+
| valign="top" | [[TWSocket.GetXPort | GetXPort]] |||| Returns the local port the socket is been bound.
 
|-
 
|-
| valign="top" | [[TWSocket.Listen | Listen]] |||| Set the socket in listening state to accept inbound connections.
+
| valign="top" | [[TWSocket.Listen | Listen]] |||| Set the socket state to "listening" to accept inbound connections.
 
|-
 
|-
 
| valign="top" | [[TWSocket.MessageLoop | MessageLoop]] |||| Pump messages until WM_QUIT is received.
 
| valign="top" | [[TWSocket.MessageLoop | MessageLoop]] |||| Pump messages until WM_QUIT is received.
Line 155: Line 159:
 
| valign="top" | [[TWSocket.MessagePump | MessagePump]] |||| Trigger [[TWSocket.OnMessagePump | OnMessagePump]] or call [[TWSocket.ProcessMessages | ProcessMessages]].
 
| valign="top" | [[TWSocket.MessagePump | MessagePump]] |||| Trigger [[TWSocket.OnMessagePump | OnMessagePump]] or call [[TWSocket.ProcessMessages | ProcessMessages]].
 
|-
 
|-
| valign="top" | [[TWSocket.Pause | Pause]] |||| Stop delivery notification of received TCP data.
+
| valign="top" | [[TWSocket.Pause | Pause]] |||| Stop delivery notifications of received TCP data.
 
|-
 
|-
| valign="top" | [[TWSocket.PeekData | PeekData]] ||||
+
| valign="top" | [[TWSocket.PeekData | PeekData]] |||| Read received data without removing it from the buffer.
 
|-
 
|-
| valign="top" | [[TWSocket.ProcessMessage | ProcessMessage]] |||| Similar as TApplication.ProcessMessage.
+
| valign="top" | [[TWSocket.ProcessMessage | ProcessMessage]] |||| Similar to TApplication.ProcessMessage.
 
|-
 
|-
| valign="top" | [[TWSocket.ProcessMessages | ProcessMessages]] |||| Similar as TApplication.ProcessMessages.
+
| valign="top" | [[TWSocket.ProcessMessages | ProcessMessages]] |||| Similar to TApplication.ProcessMessages.
 
|-
 
|-
| valign="top" | [[TWSocket.PutDataInSendBuffer | PutDataInSendBuffer]] |||| Put data in send buffer without sending it.
+
| valign="top" | [[TWSocket.PutDataInSendBuffer | PutDataInSendBuffer]] |||| Put data in the send buffer without sending the data.
 
|-
 
|-
| valign="top" | [[TWSocket.PutStringInSendBuffer | PutStringInSendBuffer]] |||| Put string in send buffer without sending it.
+
| valign="top" | [[TWSocket.PutStringInSendBuffer | PutStringInSendBuffer]] |||| Put a string in the send buffer without sending the data.
 
|-
 
|-
| valign="top" | [[TWSocket.Receive | Receive]] |||| Receive data in [[TWSocket.OnDataAvailable | OnDataAvailable]].
+
| valign="top" | [[TWSocket.Receive | Receive]] |||| Receive data (to be called within [[TWSocket.OnDataAvailable | OnDataAvailable]]).
 
|-
 
|-
| valign="top" | [[TWSocket.ReceiveFrom | ReceiveFrom]] ||||  
+
| valign="top" | [[TWSocket.ReceiveFrom | ReceiveFrom]] |||| Same as "Receive" but, also returns the sender address.
 
|-
 
|-
| valign="top" | [[TWSocket.ReceiveStr | ReceiveStr]] |||| Receive string in [[TWSocket.OnDataAvailable | OnDataAvailable]].
+
| valign="top" | [[TWSocket.ReceiveStr | ReceiveStr]] |||| Receive string (to be called within [[TWSocket.OnDataAvailable | OnDataAvailable]]).
 
|-
 
|-
| valign="top" | [[TWSocket.Release | Release]] |||| Destroy the dynamicly created TWSocket in a custom message handler.
+
| valign="top" | [[TWSocket.Release | Release]] |||| Destroy the dynamically created TWSocket in a custom message handler.
 
|-
 
|-
| valign="top" | [[TWSocket.Resume | Resume]] |||| Resume delivery notification for received data.
+
| valign="top" | [[TWSocket.Resume | Resume]] |||| Resume winsock event notifications.
 
|-
 
|-
| valign="top" | [[TWSocket.ReverseDnsLookup | ReverseDnsLookup]] ||||
+
| valign="top" | [[TWSocket.ReverseDnsLookup | ReverseDnsLookup]] |||| Start an asynchronous reverse DNS lookup.
 
|-
 
|-
 
| valign="top" | [[TWSocket.Send | Send]] |||| Send data.
 
| valign="top" | [[TWSocket.Send | Send]] |||| Send data.
Line 183: Line 187:
 
| valign="top" | [[TWSocket.SendStr | SendStr]] |||| Send a string.
 
| valign="top" | [[TWSocket.SendStr | SendStr]] |||| Send a string.
 
|-
 
|-
| valign="top" | [[TWSocket.SendTo | SendTo]] ||||
+
| valign="top" | [[TWSocket.SendTo | SendTo]] |||| Send data to a given remote socket (UDP only).
 
|-
 
|-
| valign="top" | [[TWSocket.SetLingerOption | SetLingerOption]] ||||
+
| valign="top" | [[TWSocket.SetLingerOption | SetLingerOption]] |||| Set the "linger" options defined by LingerOnOff and LingerTimeout
 
|-
 
|-
| valign="top" | [[TWSocket.Shutdown | Shutdown]] |||| Close the socket gracefull.
+
| valign="top" | [[TWSocket.Shutdown | Shutdown]] |||| Close the socket gracefully.
 
|-
 
|-
| valign="top" | [[TWSocket.TimerClear | TimerClear]] ||||
+
| valign="top" | [[TWSocket.TimerClear | TimerClear]] |||| Clear a linger timer.
 
|-
 
|-
| valign="top" | [[TWSocket.TimerCmp | TimerCmp]] ||||
+
| valign="top" | [[TWSocket.TimerCmp | TimerCmp]] |||| Compare linger timer.
 
|-
 
|-
| valign="top" | [[TWSocket.TimerIsSet | TimerIsSet]] ||||
+
| valign="top" | [[TWSocket.TimerIsSet | TimerIsSet]] |||| Check a linger timer.
 
|-
 
|-
| valign="top" | [[TWSocket.ThreadAttach | ThreadAttach]] |||| Attach the hidden window to a thread.
+
| valign="top" | [[TWSocket.ThreadAttach | ThreadAttach]] |||| Attach to the current thread.
 
|-
 
|-
| valign="top" | [[TWSocket.ThreadDetach | ThreadDetach]] |||| Detach the hidden window from a thread.
+
| valign="top" | [[TWSocket.ThreadDetach | ThreadDetach]] |||| Detach from the current thread.
 
|-
 
|-
| valign="top" | [[TWSocket.WaitForClose | WaitForClose]] ||||  
+
| valign="top" | [[TWSocket.WaitForClose | WaitForClose]] |||| Wait until the socket is closed. Better avoid this method.
 
|}
 
|}
  
Line 213: Line 217:
 
| valign="top" | [[TWSocket.OnDataSent | OnDataSent]] |||| Internal sent buffer is completely delivered to winsock.
 
| valign="top" | [[TWSocket.OnDataSent | OnDataSent]] |||| Internal sent buffer is completely delivered to winsock.
 
|-
 
|-
| width="90" valign="top" | [[TWSocket.OnDebugDisplay | OnDebugDisplay]] ||||
+
| width="90" valign="top" | [[TWSocket.OnDebugDisplay | OnDebugDisplay]] |||| To display debugging messages.
 
|-
 
|-
 
| valign="top" | [[TWSocket.OnDnsLookupDone | OnDnsLookupDone]] |||| [[TWSocket.DNSLookup | DNSLookup]] has finished.
 
| valign="top" | [[TWSocket.OnDnsLookupDone | OnDnsLookupDone]] |||| [[TWSocket.DNSLookup | DNSLookup]] has finished.
Line 219: Line 223:
 
| valign="top" | [[TWSocket.OnError | OnError]] |||| ''Discouraged'', use exception handling instead.
 
| valign="top" | [[TWSocket.OnError | OnError]] |||| ''Discouraged'', use exception handling instead.
 
|-
 
|-
| valign="top" | [[TWSocket.OnLineLimitExceeded | OnLineLimitExceeded]] |||| Denial of service attack
+
| valign="top" | [[TWSocket.OnLineLimitExceeded | OnLineLimitExceeded]] |||| A message longer than "LineLimit" has been received.
 
|-
 
|-
 
| valign="top" | [[TWSocket.OnMessagePump | OnMessagePump]] |||| To call your own message pump.
 
| valign="top" | [[TWSocket.OnMessagePump | OnMessagePump]] |||| To call your own message pump.
 
|-
 
|-
| valign="top" | [[TWSocket.OnSendData | OnSendData]] |||| Winsock send buffer is empty, will be filled again by internal send buffer if still data available to send.
+
| valign="top" | [[TWSocket.OnSendData | OnSendData]] |||| Winsock send buffer is empty, will be filled again by internal send buffer if data available to send.
 
|-
 
|-
 
| valign="top" | [[TWSocket.OnSessionAvailable | OnSessionAvailable]] |||| Client connected to this server.
 
| valign="top" | [[TWSocket.OnSessionAvailable | OnSessionAvailable]] |||| Client connected to this server.
Line 231: Line 235:
 
| valign="top" | [[TWSocket.OnSessionConnected | OnSessionConnected]] |||| Session to host etablished.
 
| valign="top" | [[TWSocket.OnSessionConnected | OnSessionConnected]] |||| Session to host etablished.
 
|-
 
|-
| valign="top" | [[TWSocket.OnSocksAuthState | OnSocksAuthState]] ||||
+
| valign="top" | [[TWSocket.OnSocksAuthState | OnSocksAuthState]] |||| State of the socks authentication process.
 
|-
 
|-
| valign="top" | [[TWSocket.OnSocksConnected | OnSocksConnected]] ||||
+
| valign="top" | [[TWSocket.OnSocksConnected | OnSocksConnected]] |||| Connected to the socks server.
 
|-
 
|-
| valign="top" | [[TWSocket.OnSocksError | OnSocksError]] ||||
+
| valign="top" | [[TWSocket.OnSocksError | OnSocksError]] |||| Triggered when an error occurs with socks server.
 
|}
 
|}
  
Line 241: Line 245:
  
 
* [[TWSocket.HowTo.Close | Close a TCP session]]
 
* [[TWSocket.HowTo.Close | Close a TCP session]]
* [[TWSocket.HowTo.Close | Destroy a dynamicly created TWSocket]]
+
* [[TWSocket.HowTo.Close | Destroy a dynamically created TWSocket]]
  
 
{{Components_Footer}}
 
{{Components_Footer}}

Latest revision as of 10:57, 6 February 2019

Main page -> ICS component reference -> TWSocket

Overview

unit OverbyteIcsWSocket.pas
inheritance TCustomThrottledWSocket (optional) -> TCustomTimeoutWSocket (optional) -> TCustomSyncWSocket -> TCustomLineWSocket -> TCustomSslWSocket (optional) -> TCustomSocksWSocket -> TCustomSocksWSocket -> TCustomHttpTunnelWSocket -> TCustomWSocket -> TIcsWndControl (*Optional = Depending on preprocessors)

TWSocket component is implementing the TCP protocol described in RFC 793 and the UDP protocol described in RFC 768. TWSocket is used in almost every other ICS component.

TWSocket component can be used as client as well as a Server socket (listening). For use as a TCP server however TWSocketServer is encouraged because it provides advanced features.

Properties

Addr Client: The host to connect to. Server: The interface to listen on.
AllSent Boolean indicating if all data in internal buffer has been sent.
BufSize Size in bytes for dynamic send buffer calls.
ComponentOptions Used to modify how the component handles some operations.
DnsResult Typically called in OnDnsLookupDone. The IP address of the remote host given as an argument to DnsLookup.
DnsResultList Similar to DnsResult but a TStringList containing the multiple IPs of the host, if appropriate.
Handle Handle for the underlying hidden window.
HSocket Winsock handle for underlying socket.
IcsLogger Linked component to log debug messages.
LastError The last error occurred during socket operation.
LineEcho Echo all received characters back to transmitter.
LineEdit Handle received control characters used for editing.
LineEnd End of line character(s) used to trigger OnDataAvailable.
LineLength When using LineMode: the length of the received line.
LineLimit Maximum line length to receive before triggering OnLineLimitExceeded. See also DOS attack.
LineMode Use LineEnd as end of line marker to trigger OnDataAvailable.
LingerOnOff Select linger mode.
LingerTimeout Select linger timeout.
ListenBacklog Size of pending connection queue in server mode.
LocalAddr The local address to which the socket is bound.
LocalPort The local port to which the socket is bound.
MultiCast Select multicast.
MultiCastAddrStr Select multicast address.
MultiCastIpTTL Select multicast "Time to Live".
MultiThreaded Set when TWSocket must use its own message pump.
PeerAddr The remote address to which the socket is bound.
PeerPort The remote port to which the socket is bound.
Port Client: The port to connect to. Server: The port to listen on.
PortNum Integer value of Port.
Proto The protocol to use, can be tcp, udp or raw.
RcvdCnt Number of characters received in internal buffer when using line mode.
RcvdCount Number of characters in receive buffer but, not read.
RcvdPtr Internal receive buffer pointer used for line mode.
ReadCount Total number of bytes received.
ReqVerLow Low part of winsock version to load.
ReqVerHigh High part of winsock version to load.
ReuseAddr Should the compnent try to reuse an address.
SendFlags How to send data.
SocketErrs How socket error messages should be presented as type TSocketErrs, wsErrTech or wsErrFriendly.
SocketFamily SocketFamily determines whether connections can use IPv4, IPv6 addresses or both, if both are available.
SocksAuthentication Select socks server authentication mode.
SocksLevel Select socks server protocol level.
SocksPassword Password for socks server authentication.
SocksPort Port number for socks server.
SocksServer IP or hostname for socks server.
SocksUsercode Usercode for socks server authentication.
State Current state of the socket; mainly used for log or display purposes.
Terminated Set to terminate synchronous operation prematurely.
Text Equivalent to ReceiveStr and SendStr.

Methods

Abort Quick and dirty way to close the socket.
Accept Accept a new incomming connection request.
CancelDnsLookup Cancel any pending DNS lookup.
Close Close the socket gracefully.
CloseDelayed Close the socket when the current event terminates.
Connect Connect to a remote host.
Create Dynamically create the component.
DeleteBufferedData Delete internal buffered data.
Destroy Destroy the dynamically created component.
DnsLookup Perform a DNS lookup of a hostname in background. See also OnDNSLookupDone.
Dup Assign a socket handle to the component.
Flush Wait until the internal buffer is flushed. Better avoid this method.
GetPeerAddr Returns the remote address the socket is bound. See also PeerAddr.
GetPeerName Returns the remote hostname the socket is bound.
GetPeerPort Returns the remote port the socket has is bound. See also PeerPort.
GetSockName Returns socket binding information.
GetXAddr Returns the local interface the socket is bound.
GetXPort Returns the local port the socket is been bound.
Listen Set the socket state to "listening" to accept inbound connections.
MessageLoop Pump messages until WM_QUIT is received.
MessagePump Trigger OnMessagePump or call ProcessMessages.
Pause Stop delivery notifications of received TCP data.
PeekData Read received data without removing it from the buffer.
ProcessMessage Similar to TApplication.ProcessMessage.
ProcessMessages Similar to TApplication.ProcessMessages.
PutDataInSendBuffer Put data in the send buffer without sending the data.
PutStringInSendBuffer Put a string in the send buffer without sending the data.
Receive Receive data (to be called within OnDataAvailable).
ReceiveFrom Same as "Receive" but, also returns the sender address.
ReceiveStr Receive string (to be called within OnDataAvailable).
Release Destroy the dynamically created TWSocket in a custom message handler.
Resume Resume winsock event notifications.
ReverseDnsLookup Start an asynchronous reverse DNS lookup.
Send Send data.
SendStr Send a string.
SendTo Send data to a given remote socket (UDP only).
SetLingerOption Set the "linger" options defined by LingerOnOff and LingerTimeout
Shutdown Close the socket gracefully.
TimerClear Clear a linger timer.
TimerCmp Compare linger timer.
TimerIsSet Check a linger timer.
ThreadAttach Attach to the current thread.
ThreadDetach Detach from the current thread.
WaitForClose Wait until the socket is closed. Better avoid this method.

Events

OnBgException Background exception occured.
OnChangeState State of TWSocket has changed.
OnDataAvailable Data available in internal receive buffer.
OnDataSent Internal sent buffer is completely delivered to winsock.
OnDebugDisplay To display debugging messages.
OnDnsLookupDone DNSLookup has finished.
OnError Discouraged, use exception handling instead.
OnLineLimitExceeded A message longer than "LineLimit" has been received.
OnMessagePump To call your own message pump.
OnSendData Winsock send buffer is empty, will be filled again by internal send buffer if data available to send.
OnSessionAvailable Client connected to this server.
OnSessionClosed Socket has closed.
OnSessionConnected Session to host etablished.
OnSocksAuthState State of the socks authentication process.
OnSocksConnected Connected to the socks server.
OnSocksError Triggered when an error occurs with socks server.

How to



ICS Components Reference