AnsweredAssumed Answered

Can't create/connect to socket

Question asked by NAZIR FOUAD on Oct 29, 2010
Latest reply on Mar 1, 2011 by David E Seymour

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,

Outcomes