Hello
I am trying write a client that sends and recieve data any time. First I wrote 
it with netconn API, since It has to listen and write simultaniously. I decided 
to migrate non-blocking api but i couldn't find any example or document. So I 
migrate to socket API.
While I was using netconn API if I send bunch of data even though I am using 
netconn_write in a loop sending single character, tcp thread was sending them 
in a single TCP packet, (code is before I tried to implement non blocking and 
only sends data)....... while (isConnected == 1) { //printf("is Connected = 
1\n");
 if(xQueueReceive(rs232QueueHandle,&serialData,300)){ //TODO: Gelen veriler TCP 
üzerinden yollanacak netconn_write //printf("gelen: %c\n",serialData); 
netconn_write(serialConn, &serialData, 1, NETCONN_COPY); 
 }
.......
But when I am using socket API it sends data as one character per tcp packet. I 
think there is a send  time out somewhere but i couldn't find it. I am thinking 
about putting socket receive and send separate threads I saw an example in lwip 
folder (rtp server example). (I saw people sent questions here but it is still 
unclear). As I understand below code works way slow then above code So there is 
no time to packet all in one packet. if I change if(queueReceive...) to while( 
queueReceive I get same behaviour but then read part is blocked. 
Should I increase tcpsend timeout (I dont know if there is setting somewhere) 
or sacrifice read part while writing or try to use seperate threads? 
while (1) { if (DHCP_state == DHCP_ADDRESS_ASSIGNED || isNetworkUP == 1) { 
printf("connecting to host...\n"); isConnected = lwip_connect(socket, (struct 
sockaddr*)&addr, sizeof(addr)); if(isConnected != 0){ printf("socket can not 
connect\n"); continue; }
 printf("Connected to host\n");
 while(isConnected == 0){     FD_ZERO(&readset);     FD_ZERO(&writeset);     
FD_ZERO(&errset);
     FD_SET(socket, &readset);     FD_SET(socket, &writeset);     
FD_SET(socket, &errset);
  ret = lwip_select(socket+1,&readset,&writeset,&errset,0);  if(ret == 0)  
continue;

  if(ret < 0)  printf("hata\n");
  if(FD_ISSET(socket,&readset)){  readCount = lwip_read(socket, &buffer, 80);  
if(readCount < 0)  lwip_close(socket);  buffer[readCount]= 0;  printf(buffer);
  }
  if(FD_ISSET(socket,&errset)){  printf("error\n");  }
  if(FD_ISSET(socket,&writeset)){  //TODO: Buraya queue üzerinden mesaj 
gönderme gelecek  //printf("write\n");  
if(xQueueReceive(rs232QueueHandle,&serialData,0)){  //printf("gelen: 
%c\n",serialData);  //lwip_write(socket, &serialData, 1);  
lwip_send(socket,&serialData, 1, NULL);  }  //lwip_write(socket,"erkan 
ersoy",11);
  } }
 } }
_______________________________________________
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

Reply via email to