I'm trying to set up a message parse on a OMAPL138 with ARM9 and DSP processors.
Using
NDK_2.24.1.18
SYS/BIOS 6.41.0.26
TI-RTOS 2.0.1.23
In the Networking Hooks I have the Network open hook calling the following, but it fails when it trys to make the socket:
int InitTCPListener() { SOCKET stcp = INVALID_SOCKET; struct sockaddr_in sin1; SOCKET stcpactive = INVALID_SOCKET; int size,tmp; SOCKET stcpbusy; struct timeval timeout; char recvbuf[100]; char sendbuf[100]; fdOpenSession(TaskSelf()); stcp = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if( stcp != INVALID_SOCKET ) goto leave; bzero( &sin1, sizeof(struct sockaddr_in) ); sin1.sin_family = AF_INET; sin1.sin_port = htons(27015); if ( bind( stcp, (PSA) &sin1, sizeof(sin1) ) < 0 ) goto leave; if ( listen( stcp, 1) < 0 ) goto leave; DbgPrintf(DBG_INFO, "Listening for connection\n"); while(1) { fd_set ibits, obits, xbits; int cnt; FD_ZERO(&ibits); FD_ZERO(&obits); FD_ZERO(&xbits); FD_SET(stcp, &ibits); if( stcpactive == INVALID_SOCKET ) { // Wait without timeout tmp = fdSelect( 4, &ibits, &obits, &xbits, 0 ); } else { // Wait for set timeout - abort active connection on no activity FD_SET(stcpactive, &ibits); tmp = fdSelect( 4, &ibits, &obits, &xbits, &timeout ); if( tmp <= 0 ) { fdClose( stcpactive ); stcpactive = INVALID_SOCKET; } } if( tmp < 0 ) goto leave; if( FD_ISSET(stcp, &ibits) ) { // We have a new connection. Assign it so sbusy at // first... size = sizeof( sin1 ); stcpbusy = accept( stcp, (PSA)&sin1, &size ); // If the active socket is free use it, else print out // a busy message if( stcpactive == INVALID_SOCKET ) stcpactive = stcpbusy; else fdClose( stcpbusy ); } if( stcpactive != INVALID_SOCKET && FD_ISSET(stcpactive, &ibits) ) { // There is data available on the active connection cnt = (int)recv( stcpactive, (char *)&recvbuf, 1024, 0 ); if( cnt > 0 ) { //PARSER WILL GO HERE BUT RIGHT NOW ECHO TO TEST //ParseCommand(recvbuf, sendbuf, 100); printf(sendbuf,recvbuf); if( send( stcpactive, sendbuf, size, 0 ) < 0 ) { fdClose( stcpactive ); stcpactive = INVALID_SOCKET; } } // If the connection got an error or disconnect, close else { fdClose( stcpactive ); stcpactive = INVALID_SOCKET; } } } leave: fdCloseSession( TaskSelf() ); }
\