Getting Started with ADSP-BF537 EZ-KIT Lite
2-13
Running a TCP/IP application on an ADSP-BF537 EZ-KIT Lite
{
struct sockaddr_in saddr;
int listenfd;
if ( 0 > ( listenfd = socket ( AF_INET, SOCK_STREAM, 0 ) ) )
{
printf ( "Call to socket() failed.\n" );
abort();
}
memset ( &saddr, 0, sizeof ( saddr ) );
saddr.sin_family = AF_INET;
saddr.sin_addr.s_addr = htonl ( INADDR_ANY );
saddr.sin_port = htons ( 23 ); /* listening on port 23
(well-known default "telnet") */
if ( -1 == bind ( listenfd, (struct sockaddr*) &saddr,
sizeof(saddr) ) )
{
printf ( "Call to bind() failed.\n" );
abort();
}
if ( -1 == listen ( listenfd, 0 ) )
{
printf ( "Call to listen() failed.\n" );
abort();
}
for ( ;; )
{
struct sockaddr cliaddr;
int clilen;
int iSocket;
iSocket = accept (listenfd, &cliaddr, &clilen);
if ( -1 == iSocket )
{
printf ( "Call to accept() failed.\n" );
abort();
www.BDTIC.com/ADI