Page 1 of 1

Understanding TCP

Posted: Fri Oct 30, 2009 4:00 pm
by noob
Hello,

Ok so I am trying to figure out how I can Open a TCP connection (listen()) and accept the connection without blocking the rest of my code, so if there is no connection present it will continue to do its data processing and when a connection appears it will service that connection with its requests, etc. I would prefer to use the task programming method, creating a task to handle the TCP connection, but I am new to embedded design and only familiar with sequential programming. So I was attempting to have an conditional test for a connection to service else continue with the main loop but it gets held up at the accept function. If I do make it in another task do I use Flags? Is there a TCP flag that will get triggered when a connection happens and that can Post the task?

Two more questions if you'll be so gracious, what does accept() return? And how does select() work?

Thank you for your time and assistance, it is greatly appreciated.

Re: Understanding TCP

Posted: Fri Oct 30, 2009 7:33 pm
by Ridgeglider
There is some discussion and well-comented explanation in the NNDK programmers Manual:
C:\Nburn\docs\NetworkProgrammersGuide, in particular see Sections 12.2.1 to 2.2.4

In additon, select(), accept(), listen(), etc. are described in
C:\Nburn\docs\NetBurnerRuntimeLibrary\NetBurnerRuntimeLibraries.pdf

Finallly, don't forget the example code:
C:\Nburn\examples\TCP, and in particular the TcpServerSelect folder.

Re: Understanding TCP

Posted: Fri Oct 30, 2009 7:41 pm
by Ridgeglider
Forgot to add:
If you need more fundamental TCP background info, the bible is TCP/IP Illustrated by W. Richard Stevens Volume 1 (of 3) in particular. It won't tell you about tasks, or uc/OS concepts though. See:
C:\Nburn\docs\NetBurnerRuntimeLibrary\uCOSLibrary.pdf for that.

Re: Understanding TCP

Posted: Sat Oct 31, 2009 3:25 pm
by noob
Thank you very much. I was using google to try and decipher the functions and it wasn't quite right.

Re: Understanding TCP

Posted: Sat Oct 31, 2009 5:45 pm
by noob
Oh I don't have this

"Finallly, don't forget the example code:
C:\Nburn\examples\TCP, and in particular the TcpServerSelect folder."

There is no TCP director, I have other TCP examples that I am using to figure out how it works, but not this particular one. Im working with the TCP2Serial example and the Telnet example

Re: Understanding TCP

Posted: Sat Oct 31, 2009 8:15 pm
by Ridgeglider
What NB release are you running? Sounds like you may be running a pretty old distribution. To find out, open the file C:\nburn\release_tag with a text editor. The current relaes is Rel23_rc7a

The C:\Nburn\examples\TCP\TcpServerSelect example folder (along with several other TCP examples) have been a part of the distribution for at least a year, since at least NNDK2.2 RC2.

The updated versions are worthwhile and highly recommended.

Re: Understanding TCP

Posted: Sat Oct 31, 2009 10:20 pm
by rnixon
I would agree with everything posted by ridgeglider, and would like to add:
- Definitely read at least the first 25 pages of the stevens book. It will save you hours of time later on.
- Start small and experiment topic by topic. Use lots of iprintf() status messages to see what is going on. Some developers frown on this, but you can leave these messages in and get a lot of good information as you develop your application.
- There is a definite learning curve to embedded programming and network communications. You are doing both at the same time. Be patient and realize you are tackling a lot at one time.

Re: Understanding TCP

Posted: Thu Nov 12, 2009 2:26 am
by noob
Hello again,

Well i have some moderate sucess, i was able to get my Mod5282 talking to a modbus master!!!

Now im working on interactive webserver for remote settings changing and am trying to go through the example in for the iadweb (section 9.5 in the Netburner Programmers Guide). As i mentioned earlier I didn't have these source codes, so I got them off the webpage. I created a new project and imported the three c files and now the console tells me "Nothing to Build"

Any clue why im getting this error?

Thanks again, you are all very helpful!!

PS. My company got the product back in May, 2008.

Re: Understanding TCP

Posted: Thu Nov 12, 2009 11:16 am
by Kiwinet
noob wrote:
I created a new project and imported the three c files and now the console tells me "Nothing to Build"
Follow this NetBurner video carefully, I think it should get around the problem, using the tictactoe example c files imported.

http://www.netburner.com/video/importin ... rting.html

Best wishes

Paul
http://www.microwebserver.net