#include <dolphin/ip.h>s32 TCPOpen ( TCPInfo* info, void* sendbuf, s32 sendbufLen, void* recvbuf, s32 recvbufLen );
TCPOpen() initializes an endpoint for TCP communication (TCPInfo).
To establish a connection to the other end, call TCPConnect().
To receive connection requests, call TCPListen().
To accept a connection request, call
TCPAcceptAsync().
The size of the send buffer should be larger then or equal to the MSS
(maximum segment size) of the networks interface to be used. The MSS of the
Ethernet interface is 1460 bytes. Since TCPSendAsync()
can directly transfers data from user memory space without copying data to the
send buffer, the send buffer larger than the MSS is not required in the GCN
stack implementation. The purpose of the send buffer is to gather small
send data into a single TCP segment to support the Nagle algorithm [RFC
896].
For the maximum throughput, the size of the receive buffer (bytes) should be more than the product of the connection bandwidth (bytes/sec) and the connection latency (sec), known as the bandwidth-delay product, but less than 65536 bytes as the current implementation does not support the TCP window scale option. The size of the receive buffer is advertised to the other end as the TCP window size.
Note: For listening TCPInfo set with TCPListen(),
neither send buffer nor receive buffer is necessary and both sizes should be set
to zero.
Once connected, data may be transferred using
TCPSendAsync() and
TCPReceiveAsync(). When a session has
been completed, TCPCloseAsync()
should be called.
info |
Pointer to TCPInfo to initialize. |
sendbuf |
The pointer to the default send buffer. |
sendbufLen |
The size of the sendbuf in bytes. |
recvbuf |
The pointer to the default receive buffer. |
recvbufLen |
The size of the recvbuf in bytes. |
IP_ERR_NONE |
Succeeded. |
IP_ERR_EXIST |
Specified socket is already in use. |
IP_ERR_INVALID |
info is NULL. |
Nagle, J., 1984, "Congestion Control in IP/TCP Internetworks", RFC 896 (Jan.).