Hello I configure my ARM as an Ethernet server and I open a desire port via tcp_listen and each loop I send data (before that I check "tcp_check_send () " and then start to transmit).my problem is when I close the first connection I can't connect again to this server.
net_initialize(); tcp_soc = tcp_get_socket (TCP_TYPE_SERVER | TCP_TYPE_KEEP_ALIVE, 0, 100, tcp_callback); if (tcp_soc >= 0) {tcp_listen (tcp_soc, 20000);} s=0; while (1) { net_main (); if (tcp_check_send (tcp_soc)){ sendbuf = tcp_get_buf (sizeof(msg)); memcpy (sendbuf, msg, sizeof(msg)); tcp_send (tcp_soc, sendbuf, sizeof(msg)); } }
I check different approaches but I can't.how can renew my connection and waiting for new client?
an other problem is when I close the connection via my pc (as a client) I see my arm still sends packages to my pc(because it's Ethernet led blink such as before) .why doesn't tcp_check_send detect connection is close?
Thanks
One possible reason is because you specified the TCP_TYPE_KEEP_ALIVE option. Refer to here www.keil.com/.../rlarm_tcp_get_socket.htm
Another possible reason is your TCP socket didn't finish the normal three-way handshake TCP closing procedure yet, so that the same TCP socket cannot be reused at once. For this you should check and learn the standard TCP state transition procedure.
Dear Chen Tang Thank you for your response. As I tested before when I remove "TCP_TYPE_KEEP_ALIVE" it causes the same problem Yes I have been read a lot about TCP/IP three handshaking but I need a function in Keil that return TCP/IP statues when it fails or our connection interrupt suddenly.
However as I told before when I disconnect from my board my server sends data after 10 seconds and it seems keil's function can't detect this situation.Am I right?
How can renew my connection ?
Hello again why does keil show me this error? obrazki.elektroda.pl/4820007200_1458552516.png
Sorry I used an old function and it causes that error. How can it possible to find out TCP/IP is timeout or TCP RETRY Time OUT ?