TWSocket.Port
Main page -> ICS component reference -> TWSocket -> Port
Contents
Definition
property Port: string;
Description
Client
This specifies the port on the server where a connect will connect you to. This only applies to TCP, since UDP doesn't use the client/server sheme. For UDP the port is nevertheless important. The UDP-socket listens on this port but for sending data to a UDP socket you don't need to connect but rather use the SendTo method instead of Send.
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