How can I detect new connections? (re: buffering data)
Ethernet Chips
No replies yet. Be the first to reply.
Join the discussion.
Ethernet Chips
No replies yet. Be the first to reply.
Join the discussion.
Share projects and connect with makers.
Joined before the site update? first.
New to WIZnet Makers?
We sent a verification link to your address. Open it to activate your account, then log in.
Accounts from this email provider are reviewed by an administrator after verification. Approval usually takes one business day.
Already have an account?
Enter your email address. If it belongs to an account, we'll send a link to set a new password. Members who joined before the site update use this to set their password.
If an account uses that address, we sent a link to set a new password. The link works once and expires in 30 minutes.
Know your password?
Need an account?
RE: How can I detect new connections? (re: buffering data)
by Eugeny ·
Generally it should be correct, and you speak very high level. When designing application, do not for get that you can not get stuck service only single socket as it may be waiting for some time to get data or change its state, and you will need some algorithm (for example, round robin) to check all the sockets and perform tasks attributed to their status.
RE: How can I detect new connections? (re: buffering data)
by sofakng ·
Sorry, but I’m still not sure how to detect a new connection using the Wiz850io and the Teensy.
For example, the W5500 has 8 available sockets.
Inside the main loop in my code, how can I check if a socket has a new connection from the last time I checked? (ie. the last loop iteration)
Unless I’m mistaken, the socket can go from SOCK_CON, to SOCK_ESTABLISHED faster than a loop iteration, so can I detect a ‘new’ connection versus an existing connection?
It seems to be a bit easier on other platforms (ie. BSD sockets), because a listening socket will create a NEW socket for every incoming connection so you can keep track of the socket handle to see if this is a new connection or an existing one.
Does that help explain my question?
RE: How can I detect new connections? (re: buffering data)
by Eugeny ·
When socket is listening, it can accept incoming connection, becoming ESTABLISHED. If, for some reason, connection drops, socket goes to state CLOSING or CLOSED, and will not accept any other incoming connections until you explicitly instruct socket to get back into listening mode.
Thus you for sure will not confuse connections because when you check for socket’s state you will see that it is not in listening (0x14) mode any more. And then, basing on status register value you have read you perform specific actions.
I recommend you to refer to W5100’s datasheet status register diagram and chapter 5 - you will see more or less comprehensive explanation how W5x00 family is programmed.
You can also see if you can use hardware interrupts from the chip, but it requires different programming approach rather than just checking status of sockets because interrupt can occur at any time and you should be sure socket handling flow is not broken.