Hello,
i am running a FTP Server on my K60 board .. with MQX3.8 ..
All is fine!
Then in another project i used a TCP Socket for some communication ..
Now i want to merge this 2 projects .. but both together don't work..
If the TCP socket is listening the FTP don't work correctly.. i can connect but not more .. "LIST" hangs up ..
now i removed the RTCS_selectall();
and the ftp is running correct, but my socket does not connect ..
here is my socket listen task ..
when i try to connect via telnet comes the error message "connection refused" ..
accept return every time RTC_SOCKET_ERROR ..
void server_task (uint_32 initial_data) { sockaddr_in laddr; uint_32 sock, listensock; int_32 error; uint_16 remote_addr_len; sockaddr_in remote_addr = {0}; uint_32 value; boolean connected=FALSE; boolean opt_bool_value; _time_delay(100); #if (WITH_SOCKET_SERVER_TASK_DEBUG==1) printf("\nstart server_task !\n");#endif laddr.sin_family = AF_INET; laddr.sin_port = SOCKET_SERVER_PORT; laddr.sin_addr.s_addr = INADDR_ANY; listensock = socket(PF_INET, SOCK_STREAM, 0); printf("STATE: %x\n", ((SOCKET_STRUCT_PTR)listensock)->STATE); if (listensock == RTCS_SOCKET_ERROR) { printf("can't create socket ..\n"); error = RTCSERR_OUT_OF_SOCKETS; } value = 256; error=setsockopt(listensock, SOL_TCP,OPT_TBSIZE,&value,sizeof(value)); if (error) { printf("something failed..1!\n"); } error=setsockopt(listensock, SOL_TCP,OPT_RBSIZE,&value,sizeof(value)); if (error) { printf("something failed..2!\n"); } opt_bool_value=TRUE; error=setsockopt(listensock, SOL_TCP,OPT_RECEIVE_NOWAIT,&opt_bool_value,sizeof(opt_bool_value)); if (error) { printf("something failed..3!\n"); } error = bind(listensock, &laddr, sizeof(laddr)); printf("STATE: %x\n", ((SOCKET_STRUCT_PTR)listensock)->STATE); if (!error) { error = listen(listensock, 0); } else { printf("something failed..4!\n"); } sock=RTCS_SOCKET_ERROR; printf("socket init done!\n"); printf("STATE: %x\n", ((SOCKET_STRUCT_PTR)listensock)->STATE); for (;;) { connected=FALSE; while (connected==FALSE) { #if (WITH_SOCKET_SERVER_TASK_DEBUG==1) printf("wait for connection..\n"); #endif _time_delay(1000); /* //sock = RTCS_selectall(0); sock=RTCS_selectset(&listensock, 1, 500); if (sock == listensock) { connected=TRUE; } else { #if (WITH_SOCKET_SERVER_TASK_DEBUG==1)||1 printf("no.. %x != %x\n", sock, listensock); #endif continue; } */ // Connection requested; accept it remote_addr_len = sizeof(remote_addr); printf("STATE: %x\n", ((SOCKET_STRUCT_PTR)listensock)->STATE); printf("try to accept socket.. sock: %x, listensock: %x\n", sock, listensock); sock = accept(listensock, &remote_addr, &remote_addr_len); printf("accepted socket! sock: %x, listensock: %x\n", sock, listensock); connected=TRUE; if (sock==RTCS_SOCKET_ERROR) { shutdown((uint_32)listensock, FTPDCFG_SHUTDOWN_OPTION); connected=FALSE; } else { #if (WITH_SOCKET_SERVER_TASK_DEBUG==1) printf("remote addr: %d.%d.%d.%d : %d connected\n", (remote_addr.sin_addr.s_addr >> 24) & 0xFF, (remote_addr.sin_addr.s_addr >> 16) & 0xFF, (remote_addr.sin_addr.s_addr >> 8) & 0xFF, remote_addr.sin_addr.s_addr & 0xFF, remote_addr.sin_port); #endif } } while (1) { // do something with connection .. } shutdown(sock, FLAG_CLOSE_TX); } printf("fatal error!\n");}
Solved! Go to Solution.
AAAAH !!
after some deep debuging into the mqx i found the problem ..
there was no free space in the socket partition .. and then i found the socket partition initialisation ..
and then i see this variable <_RTCS_socket_part_init> ..
set this variable before you create the RTCS and you can get more than 3 sockets ..
_RTCS_socket_part_init=10;error=RTCS_create();
AAAAH !!
after some deep debuging into the mqx i found the problem ..
there was no free space in the socket partition .. and then i found the socket partition initialisation ..
and then i see this variable <_RTCS_socket_part_init> ..
set this variable before you create the RTCS and you can get more than 3 sockets ..
_RTCS_socket_part_init=10;error=RTCS_create();