|
From: | Darius Babrauskas |
Subject: | Re: [lwip-users] Multi-Threaded netconn API TCP application |
Date: | Tue, 22 Sep 2015 17:01:27 +0300 |
Hi Mihai,
It looks that you have problems with
systimeouts. Each tread must have self systimeout stuct.
create_thread("client", client,
(void *)&session_index);
//PS: The application runs on Linux atm, using
lwip 1.4.0 (last stable one), the unix port from contrib directory and the
clients connect using netcat <ip> <port>.
If you using Linux, why you use LWIP?
Are you want testing?
It seem to me, that linux port not very good
implemented. Maybe for simple testing.
Darius
From: Pîrvu Mihai
Sent: Sunday, September 20, 2015 2:05 PM
To: address@hidden
Subject: [lwip-users] Multi-Threaded netconn API TCP
application Hello guys, I'm sorry if this was posted before, but i couldn't
find an answer, so I'm gonna post here in search of one.
I want to create a simple multi-threaded TCP server, that handled each new
connection on a separate thread. The listener thread will listen on the "main"
thread, and every connection will create a new thread, that will communicate
with the session created.
The code I wrote is here: http://pastebin.com/zUuTtfL0
I have dug a little into the lwip API to see how netconn_accept works and I
saw that it blocks until the "not_empty" semaphore frm the "acceptbox" mailbox
has something in it.
Now, every time this happens, I create a new thread and the session
creation is done there, and I block the main thread using the "semaphore"
variable, so a new connection doesn't happen while I still proces the old
one.
Now, the problem is pretty much this:
- I connect the first client, it works just fine
- When ANY second client tries to join, it automatically gets disconnected
and the server's console prints: Disconnected: 1, so netconn_recv doesn't return
ERR_OK.
So my question is:
- How can I create this multi-threaded enviroment so each client is
processed in a different thread?
- Also, what am I doing wrong in my current setup ?
PS: The application runs on Linux atm, using lwip 1.4.0 (last stable one),
the unix port from contrib directory and the clients connect using netcat
<ip> <port>.
Mihai
_______________________________________________ lwip-users mailing list address@hidden https://lists.nongnu.org/mailman/listinfo/lwip-users |
[Prev in Thread] | Current Thread | [Next in Thread] |