On Time RTOS-32 Documentation
Welcome
RTTarget-32
RTKernel-32
RTFiles-32
RTIP-32
RTIP-32 Programming Manual
Introduction
TCP/IP Networking
IP Packet Types
Sockets, IP, and Port Addresses
Blocking and Non-Blocking Sockets
MTU, MSS, and DCU
Fragmentation
UDP
TCP
Opening a TCP Connection
Closing a TCP Connection
TCP States
TCP Data Transfer
TCP Windows
TCP No Copy
Round Trip Time (RTT)
TCP Retransmission
TCP Keep Alive Packets
TCP Zero Window Probes
TCP Delayed Ack
TCP Silly Window Syndrome
TCP Nagle Algorithm
TCP Slow Start
TCP Congestion Avoidance
ICMP Source Quench
IGMP
Routing Table
ARP
NAT
Programming with RTIP-32
Demo Programs
PPP
DHCP Client
DHCP Server
FTP Client
FTP Server
TFTP Client
TFTP Server
Telnet Client
Telnet Server
Web Server
SNMP Agent
POP3 Client
SMTP Client
SNTP Client
SMB Server
SMB Client
SMB3 Server
SMB3 Client
WLAN Driver
RTIP-32 Reference Manual
RTPEG-32
RTUSB-32
|
Opening a TCP Connection
In order for a connection to become established, a handshake of SYNC messages and acknowledgments of the SYNC message are sent between two hosts. The connection is considered established (i.e. ready to send and receive data) when both ends have sent a SYNC message and have acknowledged the remote host's SYNC message.
A connection may be established in one of two ways:
- For passive connections, a socket is allocated by calling function socket. Its local address is set up by calling bind, then listen is called. The function listen sets the socket to be a master socket/listener socket. The opening handshaking is started when the remote host sends a Sync message. When a Sync message is received for that socket, a new socket (slave socket) is allocated to process the connection. A SYNC message and an acknowledgment of the SYNC received will be sent to the remote host. The application needs to call accept after listen. The function accept will return the slave socket when the connection is established.
- For active connections, a socket is allocated by calling socket. Then, connect is called. Calling bind is optional. The function connect will initiate the handshaking by sending a SYNC message to the remote host. In blocking mode, connect will return when the connection has become established.
Note that if the socket is in non-blocking mode, connect will return immediately after sending the SYNC message and select may be called to block until the connection is established.
TCP
Closing a TCP Connection
|