Difference between revisions of "TWSocket.Addr"

From Overbyte
Jump to navigation Jump to search
 
 
(15 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 +
[[Main_Page | Main page]] -> [[ICS_Components_Reference | ICS component reference]] -> [[TWSocket]] -> [[TWSocket.Addr | Addr]]
 +
 +
== Definition ==
 +
 +
'''property''' Addr: '''string''';
 +
 +
== Description ==
 +
 
=== Client ===
 
=== Client ===
  
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, so [[TWSocket.DNSLookUp | DNSLookUp]] is perferable.
+
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.
  
 
=== Server ===
 
=== Server ===
  
The interface to listen on. '''0.0.0.0''' means all interfaces.
+
The interface to listen on. ''0.0.0.0'' means all interfaces. Note that for a TCP server the use of [[TWSocketServer]] is preferable.
 +
 
 +
=== Special IP addresses ===
 +
* 0.0.0.0 means all interfaces (server only)
 +
* 127.0.0.1 is the localhost, useful for testing purposes since the packets don't leave the own PC or if you don't know the IP of the local PC.
 +
 
 +
== Example ==
 +
 
 +
== Best practices ==
 +
 
 +
== How to ==
 +
 
 +
* Listen on multiple interfaces
 +
 
 +
:You may listen on one interface (giving its 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.
 +
 
 +
:Note that this counts for a UDP listener and that for a TCP server the use of [[TWSocketServer]] is preferable.

Latest revision as of 09:03, 1 August 2008

Main page -> ICS component reference -> TWSocket -> Addr

Definition

property Addr: string;

Description

Client

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.

Server

The interface to listen on. 0.0.0.0 means all interfaces. Note that for a TCP server the use of TWSocketServer is preferable.

Special IP addresses

  • 0.0.0.0 means all interfaces (server only)
  • 127.0.0.1 is the localhost, useful for testing purposes since the packets don't leave the own PC or if you don't know the IP of the local PC.

Example

Best practices

How to

  • Listen on multiple interfaces
You may listen on one interface (giving its 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.
Note that this counts for a UDP listener and that for a TCP server the use of TWSocketServer is preferable.