
SDK Programming Guide Version 1.511
ABLELink
R
Ethernet-Serial Server MAXI Series
tcp_receive()
Description:
Receive data from the remote site via TCP connection.
Include:
tcpapi.h, tcpdef.h
Usage: int tcp_receive (int
handle
, char far *
pbuf
, unsigned short
len
, farFUNC
postfunc
, char far *
parg
)
handle:
the unique handle of the established connection
postfunc:
entry point of the post-function
parg:
the pointer of arguments to pass to post-function
pbuf:
the pointer of receive buffer
Input Parameters:
len:
data length
Return Value:
SUCCESS
connect is successful
others
error, please refer to the file
tcpdef.h
Example:
receive data once the connection is established.
listen_post(....) or connect_post(....)
{
if(cb->retcode == SUCCESS )
{
tcp_receive( handle, buf, len, receive_post, arg)
;
:
}
}
receive_post(....)
{
if(cb->retcode == SUCCESS )
{
:
//Process incoming data
,
and then
:
//issue tcp_receive(....) again
tcp_receive( handle, buf, len, receive_post, arg)
;
}
}
Remarks:
This function is used to get data from the remote site via the established
connection. The maximum data length is 1460 bytes. In the post-function,
you can check whether this function is successful or not. If successful, then
you can process the incoming data. Normally, the first time to call
tcp_receice is in the
tcp_listen
or
tcp_connect
post-function. In the
tcp_receive
post-function, you can issue
tcp_receive
again.
Copyright © 2004 Atop Technologies, Inc.
All rights reserved. Designed in Taiwan.