Running a TCP server with InterNiche stack in superloop mode

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

Running a TCP server with InterNiche stack in superloop mode

2,927 Views
pnordby
Contributor I
I have posted some details in another thread here. Since then, I have been able to figure out some of the stuff by examining several versions of TCP servers in this forum.

My next problem might be related to functionality inside the stack:
  1. I sometimes get "calloc1 failed: size: 130, failures: 1" on disconnect after sending and receiving data.
  2. When disconnecting after having two simultaneous connections, the sw can lock up and stop responding to more TCP activity.
  3. Besides the totally missing documentation of msring functions (code is doc?), the mini socket functions could also clearly be better described. I wonder if m_ioctl() should be called on sockets returned from m_listen() or on the sockets returned from msring_del().
Does anyone have any experience with similar problems?

A few details which have changed or evolved since my previous thread posting:
  • Call tcp_tick() inside the timer_isr() function
  • Call pktdemux() from the superloop (e.g. somewhere in main())
  • Do not call inet_timer() or packet_check() in the timer_isr() function
  • I can successfully establish two simultaneous connections to the same port, and send/receive data correctly to each of them (verified with manually with netcat and "echo" functionality in my sw)
Does anyone else have details from a superloop tcp server?
Labels (1)
0 Kudos
4 Replies

485 Views
pnordby
Contributor I
Ahh... got it.

The details I failed to notice was:
m_listen() returns a server socket thing, which should not be used for communication or closed. There is no need to open or close new sockets (or start something which results in this) on connect in the m_listen-callback function.

Several (all?) of the TCP server examples here does not seem to pay enough attention to this.

Now, the next thing:
At some point (e.g 3 connections), I would like to refuse additional connect rather than failing or crashing. Has anyone succeeded in this without closing the already established connections?

(I seem to be replying to myself only - is anybody alive in this forum?)
0 Kudos

485 Views
cHeller
Contributor I
Now, the next thing:
At some point (e.g 3 connections), I would like to refuse additional connect rather than failing or crashing. Has anyone succeeded in this without closing the already established connections?

--------------------------------------------------------------------------------------------------

Can anyone send a snippet of code for how this is done?  Specifically, I have a telnet server, and I only want to support ONE connection.  How do I gracefully refuse the 2nd connection?

I followed this thread and apparently the code for the whole example could not be posted.  But the fragment that I need is not supplied by InterNiche.

Thanks for all help!

-ch

0 Kudos

485 Views
mccPaul
Contributor I
We are here, but you seem to be getting on very well without us!
 
Mostly, you should get a reply to a post within a day or so if someone is easily able to help. The InterNiche stack seems to have a few documentation and code weaknesses and a number of them have been addressed by the community.
 
CHeers,
 
Paul.
0 Kudos

485 Views
pnordby
Contributor I
This topic has more details here.
0 Kudos