Can't create/connect to socket

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Can't create/connect to socket

Jump to solution
1,437 Views
livy1234
Contributor I

Hi,

I followed instuctions from webinar to create a TCP/IP interface and connect to socket.

The interface is created and is pingable- but i can't connect to socket

 

here's my code

 uint_32     error;
 uint_32     sock, listensock;
 sockaddr_in    addr;
 char     str[] = "\nHello ZEFT\n";
    int len;
    
    

   _io_socket_install("socket:");
   _io_telnet_install("telnet:");
  

   error = RTCS_create();


   _IP_forward = TRUE;
   IPCFG_default_enet_device = ENET_DEVICE;
   IPCFG_default_ip_address = ENET_IPADDR;
   IPCFG_default_ip_mask = ENET_IPMASK;
   IPCFG_default_ip_gateway = 0;
 
   ENET_get_mac_address (IPCFG_default_enet_device, IPCFG_default_ip_address, IPCFG_default_enet_address);
  
   ipcfg_init_device (IPCFG_default_enet_device,IPCFG_default_enet_address);
   error = ipcfg_bind_staticip(IPCFG_default_enet_device, &IPCFG_default_ip_address);

 

 listensock = socket (PF_INET, SOCK_STREAM, 0);

 /* bind the socket to a port */
 addr.sin_family = AF_INET;
 addr.sin_port = 23;
 addr.sin_addr.s_addr = INADDR_ANY;


 error = bind(listensock,&addr,sizeof(addr));
 error = listen(listensock,0);

   for (;:smileywink: 
   {


      sock = accept(listensock,NULL, NULL);
           
  if (sock != RTCS_SOCKET_ERROR)
  {
   send(sock,str,sizeof(str)-1,0);
   shutdown(sock,FLAG_CLOSE_TX);
  }

 
   }

 

 

when i try to debug it... as soon as the code gets to sock = accept (listensock,NULL,NULL) it disrupts the program.

 

please help me anyone,

I spent two days staring at this code

thanks,

0 Kudos
Reply
1 Solution
689 Views
DavidS
NXP Employee
NXP Employee

Hi Livy1234,

What training?

Do you have link to send?

Did you recompile the RTOS to ensure the libraries were up-to-date?

Have you tried any of the existing demo's?  Look in FSLMQX/rtcs/examples/shell and try running it and let me know if that is working.

Regards,

David

View solution in original post

0 Kudos
Reply
3 Replies
689 Views
livy1234
Contributor I

By the way, this is running on the MCF52233 EVAL board

thanks a bunch

0 Kudos
Reply
690 Views
DavidS
NXP Employee
NXP Employee

Hi Livy1234,

What training?

Do you have link to send?

Did you recompile the RTOS to ensure the libraries were up-to-date?

Have you tried any of the existing demo's?  Look in FSLMQX/rtcs/examples/shell and try running it and let me know if that is working.

Regards,

David

0 Kudos
Reply
689 Views
Tommy_Liu
Contributor II

Dear, I have meet the same problem. Have you resolved it?:manmad:

0 Kudos
Reply