TWSocket.Addr

From Overbyte
Jump to: navigation, search

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.