hey I'm using the coldfire-lite tcp client. The board that I'm using is m52233DEMO.I can connect to the server this is working fine. But I wan't to know how to program my board to try continuously make a connection even if the server is not running. But when I reset or shutdown the server or the board the board has to reconnect but that isn't working.
some information about the server: The server auto drops the connection when there is no reply of board the server knows this because the board is sending a keep_alive to the server. When there is no keep_alive send the server wait's for about 5s and then disconnect the board.
this is a part of code of my tcp_init
int freescale_tcp_init()
{
const char* loginname;
semaphore = 0;
flash_ffs_lockout = 0;
emg_tcp_communication_socket = INVALID_SOCKET;
// Init message queue for MINI_TCP socket interface
msring_init(&emg_tcp_msring, emg_tcp_msring_buf, sizeof(emg_tcp_msring_buf) / sizeof(emg_tcp_msring_buf[0]));
// Init a socket structure with our Port Number
emg_tcp_sin.sin_addr.s_addr = (SERVER_IP);
emg_tcp_sin.sin_port = (PORT_NUMBER);
emg_tcp_communication_socket = m_socket();
printf( "\nConnecting to target..." );
//m_ioctl(emg_tcp_communication_socket, SO_NONBLOCK, NULL); //make socket non blocking
e = m_connect(emg_tcp_communication_socket, &emg_tcp_sin, freescale_tcp_cmdcb );
if ( e > 0 )
{
send_alive = 1;
if( e == ECONNREFUSED )
{
printf( " - Cold Not Find Target, reset" );
freescale_tcp_init();
emg_tcp_communication_socket = INVALID_SOCKET;
m_close (emg_tcp_communication_socket);
m_close (emg_tcp_server_socket);
}
else
printf(" - error %d starting listen on emg TCP server\n", e);
freescale_tcp_init();
emg_tcp_communication_socket = INVALID_SOCKET;
m_close(emg_tcp_communication_socket);
m_close(emg_tcp_server_socket);
m_ioctl(emg_tcp_communication_socket, SO_NONBLOCK, NULL); //make socket non blocking
}
if (e == 0)
{
emg_tcp_server_socket = emg_tcp_communication_socket;
.....
Solved! Go to Solution.
The actual TCP fix is located in the file TCPAPI.C, which is buried in some folder in the Coldfire Lite project. To make things simple, I have attached the fixed version of that file to this message.
- Marc
Thanks for the reply but i got still one error.
I made a loop. Then he says about 18 times "cold not find target, reset". Then he gives an error that there is no memory left. I was searching and i found he did an alloc. So he makes a reservation for some memory 18 times. I think i have to do something with free my memory. I found something like TCB_FREE. I tried somethings but i still get acces error. Does anyone can help me.
Thanx
You set up the connection using the m_connect function. This function returns 0 when successful, and nonzero when it fails. It is up to the code to re-attempt to connect to the server. You will probably have to set up some kind of loop to do this...
I hope this is what you were asking?
The actual TCP fix is located in the file TCPAPI.C, which is buried in some folder in the Coldfire Lite project. To make things simple, I have attached the fixed version of that file to this message.
- Marc
Hello Jonas,
I too use the Coldfire Lite TCP client in my project. I have found that, when the TCP client tries to connect to a server that does not respond, it gets trapped in a wait loop that does not contain a timeout, so it will remain in this loop forever.
I have created a simple fix for this. You can find the fix in a document I posted here recently, see this thread:
http://forums.freescale.com/freescale/board/message?board.id=CFCOMM&thread.id=6625
If you have any questions about this, just let me know!
- Marc
Hi Marc ,
I cannot find any solution in the given link by you . can you attach the solution in the reply itself.\
Thanks
Nisha