TWSocket.Port

From Overbyte
Revision as of 10:00, 12 September 2006 by Markus.humm (talk | contribs) (added examples)
Jump to navigation Jump to search

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

Definition

property Port: string;

Description

Client

This specifies the port on the server where a connect will connect you. This only applies to TCP, since UDP doesn't use the client/server sheme.

Server

The port on the interface where the server will listen either for incomming connections and data (TCP) or for data only (UDP). If a TCP server specified '0.0.0.0' for Addr, the port is available on all IP-adresses the server currently posseses (including 127.0.0.1 and dial in internet connections).

Under windows the netstat command may be used to check which ports are already in use and by what application. Call netstat -? for details on its usage.

Example

TCP client

 WSocket1.addr:='192.168.0.1'; // Address to connect to
 WSocket1.port:='5000';        // Port to connect to
 WSocket1.proto:='tcp';
 WSocket1.connect;             // actually do the connect

TCP server

 WSocket1.addr:='192.168.0.1'; // Address to connect to
 WSocket1.port:='5000';        // Port to connect to
 WSocket1.proto:='tcp';
 WSocket1.listen;              // wait for incomming connections 
                               // but return immediatelly

UDP

 WSocket1.addr:='192.168.0.1'; // Address to connect to
 WSocket1.port:='5000';        // Port to connect to
 WSocket1.proto:='udp';
 WSocket1.listen;              // incomming data will directly raise 
                               // OnDataAVailable

Best practices

How to