This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Question about TCP layer in RedBoot


I've sent the answer to your question to the list so that
others might also benefit from it.  
http://www.catb.org/~esr/faqs/smart-questions.html#forum

[Private support is available for a fee.]

On Fri, Oct 07, 2005 at 01:47:34AM +0800, Hunag Sun I wrote:

> Firstly, thank you for replying. In TCP layer,there are no
> APIs,like bind(),accept(),socket(), these are necessary for
> "server" application.

Those are necessary for the BSD/Posix API.  They are not
necessary for a server application as long as there is a way to
accomplish the same thing.

> I can't see any server application and these APIs in
> ./packages/redboot/current/src/net.

Look in net_io.c

In net_io_init() there's a call to __tcp_listen() to set up a
tcp socket listing on a port.

In net_io_test(), there's code that checks for new connections.

In _net_io_getc_nonblock() there's code that checks for rx data
and then calls __tcp_read().

In general look for __tcp_xxxx() functions.

> Could you tell how to find them out or any way possiable for
> my "server" implementation.

Here's a rough outline:

 1) Declare a tcp_socket_t structure.

 2) Call __tcp_listen() to attach that structure to a port.

 3) Check the socket structure state field once in a while.
    When it changes to _ESTABLISHED, you've got a connection.

 4) Periodically check for rx data, if there is some, call
    __tcp_read() to read data and then __tcp_write() to write
    data.

 5) When you're done, call __tcp_close()

 6) Wait for the state to transition to _CLOSED.

 7) If you want to accept a new connection, goto 2) 


-- 
Grant Edwards
grante@visi.com

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]