IwIP

Xin WANG <[email protected]>
Newsgroups gmane.linux.real-time.rtlinux.general
Message-ID <[email protected]>
Hi,
   I changed example "tcp_echo_multithread" to test how many sockets i
can open simultanously. The code is much simipler than it before. It
does nothing excpet waiting for 4 connections and CLOSING THEM IN
CLEANUP_MODULE(). The problem is that it takes too long time to accpet
3th connection and when i rmmod it prints a lot of p != NULL.Why?
Thanks!


This is my code:
--------------------------------------------------------------------
#include <linux/module.h>
#include <linux/kernel.h>
#include "lwip/sys.h"
#include "lwip/api.h"
#include <rtl_sched.h>
#include <rtl_debug.h>

#define NUM_OF_CONN 4
struct netconn *newconn[NUM_OF_CONN];

static void 
tcpecho_thread(void *arg)
{
  struct netconn *conn;
  int i;

   /* Create a new connection identifier. */
  conn = netconn_new(NETCONN_TCP);

  /* Bind connection to well known port number 7. */
  netconn_bind(conn, NULL, 7);

  /* Tell connection to go into listening mode. */
  netconn_listen(conn);

  for(i=0;i<NUM_OF_CONN;i++) {
    newconn[i]=netconn_accept(conn);
    rtl_printf("%d accepted\n", i);	
  }
}

int init_module(void){
  printk("\n Multithreaded TCP echo server inserted\n");
  sys_thread_new(tcpecho_thread, NULL, 0);  
  return 0;
}

void cleanup_module(void){
  int i;
  for(i=0;i<NUM_OF_CONN;i++){
    netconn_close(newconn[i]);
    netconn_delete(newconn[i]);
  }
  printk("\n Multithreaded TCP echo server removed\n");
}
_______________________________________________
Rtl mailing list
[email protected]
http://www2.fsmlabs.com/mailman/listinfo/rtl
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.