Hi,i am using CCS 6.1 / NDK 2.25.00.09 / NSP 1.10.03.15. How i can change UDP port in my code below without DaemonFree() ?
This code is working properly and i can change ip address or gateway(using CfgGetEntry(), CfgRemoveEntry(), CfgAddEntry()). But what about UDP port ?
(In NDK configuration autoOpenCloseFD = true;)
/* Init udp daemon */ void netOpenHook() { udpStart = DaemonNew( SOCK_DGRAM, 0, PORT_UDP, recUDP, 1, 16384, 0, 1 ); sendudp = TaskCreate( tskUdpSend, "SendUDP", OS_TASKPRINORM, 2048, 0, 0, 0 ); } uint8_t *pDat; /* Receive frame and put him in circular buffer for parsing */ int recUDP( SOCKET s, UINT32 unused ) { int rxSize, i , tmp; for(;;) { tmp = sizeof( sin1 ); currentSoc = s; rxSize = (int)recvncfrom( s, (void **)&pDat, 0, (PSA)&sin1, &tmp, &hBuffer ); if( rxSize >= 0 ) { for( i = 0; i < rxSize; i++) putBuffer(*pDat++);// analyzing data and create answer recvncfree( hBuffer ); } } fdClose(s); return(0); } /* Send UDP */ void tskUdpSend() { while(1) { Semaphore_pend(semDatagramIsFull, BIOS_WAIT_FOREVER); // wait answer sendto( currentSoc, txDatagram , sizeD, 0, (PSA)&sin1, sizeof(sin1) ); memset(txDatagram, 0, sizeof(txDatagram)); } }
I am trying use DaemonFree(), but after DaemonFree()->fdCloseSession()->llExit() i turn out in UDP callback and function recvncfrom() always return -1 .