This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

NDK example for socket in CCS

Hi,

I am using the TMS320C6A8167 integra board and CCSv5.5 to connect to the ARM core. I want to run a simple socket program that gets packets from the Ethernet and stores it in memory I have included the socket.h and init.h files from the ndk folder of MCSDK, but I am getting errors about UINT8/16/32 being not defined and HANDLE not defined etc. my code:

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<inet.h>
#include<socket.h>
#include<ctype.h>

#define BUFLEN 1500  //Max length of buffer
#define PORT 8080   //The port on which to listen for incoming data

int counter =0;

void die(char *s)
{
    perror(s);
    exit(1);
}

int main(int argc , char**argv)
{

struct sockaddr_in server_addr, client_addr;

int sockfd , i, slen = sizeof(client_addr) , recv_len ;

char buf[BUFLEN];

if ((sockfd=socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1)
{
    die("socket");
}


memset((char *) &server_addr, 0, sizeof(server_addr));  // replaces the client addr to 0

server_addr.sin_family = AF_INET;
server_addr.sin_port = htons(PORT);
server_addr.sin_addr.s_addr = htonl(INADDR_ANY);



client_addr.sin_family = AF_INET;


if( bind(sockfd,(struct sockaddr*)&server_addr, sizeof(server_addr) ) == -1)
{
    die("bind");
}

while(1)
{

    //printf("Waiting for data...");
    fflush(stdout);

    if ((recv_len = recvfrom(sockfd, buf, BUFLEN, 0, (struct sockaddr *) &client_addr, &slen)) == -1)   // read datagram from server socket
    {
        die("recvfrom()");
    }
    counter++;
    //sendto(sockfd, buf, recv_len, 0, (struct sockaddr*)&client_addr, slen) ;

    //printf("Received packet from %s:%d\n", inet_ntoa(client_addr.sin_addr), ntohs(client_addr.sin_port));
    printf("Data: %s\n" , buf);
	printf("counter: %d\n",counter);

}

}

the following screen shot gives the errors:

are there some example projects for arm where I can see how to use the header files.

Thanks

Raunak