1.建议回调方式,因为V4.74版本的,如果采用阻塞方式读取的话,将会限制发送。就是说等待接收的过程中,是没法进行数据的发送的。最新版本无限制。
2.TCPnet uses the return value of the callback function listener only when the event is TCP_EVT_CONREQ. It uses the return value to decide whether to accept or reject an incoming connection when the TCP socket is listening. If the listener function returns 1, TCPnet accepts the incoming connection. If the listener function returns 0, TCPnet rejects the incoming connection. You can thus define the listener function to selectively reject incoming connections from particular IP addresses.
只有当事件为tcp_evt_conreq时,tcpnet才使用回调函数listener的返回值。它使用返回值来决定在TCP套接字侦听时是否接受或拒绝传入连接。如果listener函数返回1,tcpnet接受传入连接。如果listener函数返回0,tcpnet将拒绝传入连接。因此,您可以定义listener函数来有选择地拒绝来自特定IP地址的传入连接。(译文来自百度翻译)