Hello,
I’m trying to run the http server and another tcp socket listening in port 6000 but it seems that it can’t run at the same time.
If I put a socket listening with tcp_listen before http_init seems that de http server don’t process any request and when I put tcp_listen after http_init() I can’t connect to that socket but the http server works fine.
How I can listen to a tcp socket and use the http daemon at the same time?
tcp_listen(&socket,6000,0,0,NULL,0);
http_init();
tcp_reserveport(80);
...
while (1)
{
http_handler();
conectado=0;
endtime = MS_TIMER + (5*1000);
if(tcp_listen(&socket,PORT_TCP,0,0,NULL,0)==0)
{
printf("Ha fallado el listen antes de la espera
");
}
printf("Espero 5s a una conexion TCP
");
while ((long)MS_TIMER - endtime < 0) {
if(tcp_tick(NULL)==0)
{
//printf("tcp_tick ==0
");
}
if(sock_established(&socket))
{
printf("Pongo conectado a 1
");
conectado=1;
break;
}
}
printf("Espera terminada
");
if(conectado==1)
{
printf("Connection received...
");
do {
bytes_read=sock_fastread(&socket,buffer_socket,sizeof(buffer_socket));
if(bytes_read>0)
{
sock_write(&socket,buffer_socket,bytes_read);
}
} while(tcp_tick(&socket));
printf("Connection closed...
");
}
}
Excuse my bad English…