Hello,
I'm using RL-TCPnet with RTX in order to develop an Modbus TCP application. Everything works fine until the application tries to send some packet greater than 1460 bytes of data.
I'm using tcp_max_dsize and tcp_send to handle the response packets, but tcp_send only accepts packets up to 1460 bytes. When I tried to split the big packet in smaller chuncks of data the tcp_send functions returned FALSE after the first packet had been sent.
I belive that TCP stack should handle large packets and split then when its size are greater than maximum packet size.
Should I use other function?
Is there a better way to send large bunch of data using tcp sockets?
My MDK is 4.7.
Best regards.
Hello again,
I am trying to change my application from TCP sockets to BSD sockets as mentioned. I still using init_tcp() and main_TcpNet() calls in order to enable ICMP to work.
My main task is like the following:
__task void ethCOMLoop( void ) { ...
SocketFD = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); ack_mode = 1; res = ioctlsocket (SocketFD, FIO_KEEP_ALIVE , &sck_mode); /* keep alive */
memset(&sa, 0, sizeof sa);
sa.sin_family = AF_INET; sa.sin_port = htons(1001); sa.sin_addr.s_addr = htonl(INADDR_ANY);
bind(SocketFD, (struct sockaddr *)&sa, sizeof sa) ;
listen(SocketFD, 10) ;
while( 1 ) { if ( ETHInitialized ) { int ConnectFD; int peerSize = sizeof(struct sockaddr_in);
ConnectFD = accept(SocketFD, (struct sockaddr *)&peer, &peerSize );
if (0 > ConnectFD) { /* ALWAYS -2 =/ */ status = -1; } else {
// proccess data... } main_TcpNet(); } }
However, I still cannot accept incoming attempts of connection. Accept function always returns -2 (SCK_EINVALID), even with socket(), bind() and listen() functions returning success.
Is there something I am missing?
Again, thanks a lot for your support so far.
listen(SocketFD, 10) ; while( 1 ) { ConnectFD = accept(SocketFD, (struct sockaddr *)&peer, &peerSize ); }
The accept() function creates a new socket for each connection and removes the connection from the listen queue.
Some update...
After some work, I managed to make BSD sockets work, receiving and sending packets. However, I still have fragmentation problems.
Using send() function and disabling block option for sockets my system works fine until I try to send some data greater than 1460 bytes. Send() function returns 1460 bytes sent, but do not finishes the transmission of the remaining data. I tried to call send() in a loop, but after first call it returns error code.
Should I call main_TcpNet() after first send()? I was unable to find documentation or examples using BSD API with RTX and TCPnet (calls to main_TcpNet()).
Enabling block option for sockets, system halts its execution.
Until now still cannot make it work =/.
Application works fine with BSD sockets, but, when I try to send packets larger than 1460B, the send() function send only 1460B (non blocking) or stall the RTX system (blocking mode). I have tried to put main_tcpNET function in other tasks without success.
Have anyone some tip/advice on using BSD sockets, server mode, with RTX?
Best regards,
Take a look at BSD_client example configuration.
Reporting here that I manage to make TCPNet library works in my application and correctly fragment packets, however, I would like to share some difficulties that I faced: * BSD sockets must be in blocking mode to fragment packet; * In multi-thread system, blocking BSD sockets may halt execution of other low prio tasks (USB tasks in my case); * To make my application work properly, I'm using non-blocking sockets and, when fragmentation is needed, changing the sockets to blocking mode, send data and switch back to non-blocking; * Data exchange with blocking BSD API is slower than TCP API. For my application, data transfers that are done at 100kbps using USB goes up to max 40kbps using ethernet BSD; * BSD API is poorly documented and have only a few examples that does not cover many applications.
Thank you guys, for the support.