469,923 Members | 1,459 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,923 developers. It's quick & easy.

source code for tcp/ip stack

hello can anbody help me in getting source code for tcp/ip stack in
ANSI C or source code for http protocol

Apr 28 '06 #1
7 5035
sandy opined:
hello can anbody help me in getting source code for tcp/ip stack in
ANSI C or source code for http protocol


What's wrong with Google? You used it to post this.

--
linux: because a PC is a terrible thing to waste
(ks*@cis.ufl.edu put this on Tshirts in '93)

<http://clc-wiki.net/wiki/Introduction_to_comp.lang.c>

Apr 28 '06 #2
In article <a-********************@bt.com>,
Vladimir Oka <no****@btopenworld.com> wrote:
sandy opined:
hello can anbody help me in getting source code for tcp/ip stack in
ANSI C or source code for http protocol

What's wrong with Google? You used it to post this.


It would take rather a lot of googling to find source code for
a TCP/IP stack written in standard ANSI C, as the C standards
know nothing about the existance of networks. Any TCP/IP stack
would have to contain operating-system specific calls
that are beyond the scope of the C standards.

In order to write a TCP/IP stack, at the very minimum one
needs to have a routine to accept a packet from hardware,
and another to dispatch an arbitrary packet towards hardware.
Such low-level calls are not available even in POSIX.1.
Source code for the http protocol is also problematic, but for
a different reason: a -protocol- is not the same thing as
an -implementation- of the protocol. There are many implementations
available (such as Apache) -- none of which can be written purely
in standard C though.
--
If you lie to the compiler, it will get its revenge. -- Henry Spencer
Apr 28 '06 #3
In article <e2**********@canopus.cc.umanitoba.ca>,
Walter Roberson <ro******@ibd.nrc-cnrc.gc.ca> wrote:
In order to write a TCP/IP stack, at the very minimum one
needs to have a routine to accept a packet from hardware,
and another to dispatch an arbitrary packet towards hardware.
Such low-level calls are not available even in POSIX.1.


That's not much of a problem, since a couple of calls to functions
defined elsewhere doesn't affect the standard-C-ness of the stack
itself. A more serious problem is that a real implementation is
likely to use virtual memory tricks to avoid copying data, and will be
designed to fit into some particular operating system.

-- Richard
Apr 28 '06 #4
In article <e2***********@pc-news.cogsci.ed.ac.uk>,
Richard Tobin <ri*****@cogsci.ed.ac.uk> wrote:
In article <e2**********@canopus.cc.umanitoba.ca>,
Walter Roberson <ro******@ibd.nrc-cnrc.gc.ca> wrote:
In order to write a TCP/IP stack, at the very minimum one
needs to have a routine to accept a packet from hardware,
and another to dispatch an arbitrary packet towards hardware.
Such low-level calls are not available even in POSIX.1.

That's not much of a problem, since a couple of calls to functions
defined elsewhere doesn't affect the standard-C-ness of the stack
itself.
For the purposes of this newsgroup, the only ANSI C programs
are those for which all the source could {theoretically} be examined
and found not to use any extensions or constructs or system calls
not documented as the ANSI/ISO standards as existing.

I suppose in theory one -could- have an OS in which packetization
was accomplished by fopen()/fclose() on a magic filename -- the result
wouldn't be much portable, but the code could be ANSI C. Failing
that, ANSI C does not provide any method to signal the end of a packet
within a stream. To stay entirely within ANSI C would then require
use of features documented as implementation-defined -- in particular,
of converting an integral value to a pointer and dereferencing
in order to access memory-mapped hardware. That would be ANSI C, but
not portable... I suppose you just -might- find source for such a
thing via google, if you looked long enough (or knew exactly what
you were looking for.)

A more serious problem is that a real implementation is
likely to use virtual memory tricks to avoid copying data, and will be
designed to fit into some particular operating system.


But virtual memory tricks are inherently tricks with memory-mapped
locations, so the integer -> pointer conversion would have a better
chance of being meaningful ;-)
--
I was very young in those days, but I was also rather dim.
-- Christopher Priest
Apr 28 '06 #5
Richard Tobin wrote:
In article <e2**********@canopus.cc.umanitoba.ca>,
Walter Roberson <ro******@ibd.nrc-cnrc.gc.ca> wrote:

In order to write a TCP/IP stack, at the very minimum one
needs to have a routine to accept a packet from hardware,
and another to dispatch an arbitrary packet towards hardware.
Such low-level calls are not available even in POSIX.1.

That's not much of a problem, since a couple of calls to functions
defined elsewhere doesn't affect the standard-C-ness of the stack
itself. A more serious problem is that a real implementation is
likely to use virtual memory tricks to avoid copying data, and will be
designed to fit into some particular operating system.

There are several "tiny" IP stacks out there designed for 8 bit embedded
use that should meet the OP's requirements. I haven't trawled the
source for ANSI compatibility, but these stacks are designed for
portability.

Spend some time with Mr. Google.

--
Ian Collins.
Apr 28 '06 #6
In article <4b*************@individual.net>,
Ian Collins <ia******@hotmail.com> wrote:
There are several "tiny" IP stacks out there designed for 8 bit embedded
use that should meet the OP's requirements. I haven't trawled the
source for ANSI compatibility, but these stacks are designed for
portability.


The uIP stack is one example,
http://www.sics.se/~adam/uip/

It is fairly cleanly written, but if one digs down far enough,
it relies upon the "tapdev" device driver which is written
in terms of ioctl(). The non-portable portion is certainly
isolated, but it's still non-portable.
--
There are some ideas so wrong that only a very intelligent person
could believe in them. -- George Orwell
Apr 28 '06 #7
Walter Roberson wrote:
In article <4b*************@individual.net>,
Ian Collins <ia******@hotmail.com> wrote:

There are several "tiny" IP stacks out there designed for 8 bit embedded
use that should meet the OP's requirements. I haven't trawled the
source for ANSI compatibility, but these stacks are designed for
portability.

The uIP stack is one example,
http://www.sics.se/~adam/uip/

It is fairly cleanly written, but if one digs down far enough,
it relies upon the "tapdev" device driver which is written
in terms of ioctl(). The non-portable portion is certainly
isolated, but it's still non-portable.


True, you will hit the hardware or OS at some point, but as a stack,
this is a good, clean example.

--
Ian Collins.
Apr 28 '06 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

29 posts views Thread by Bill Marsden | last post: by
16 posts views Thread by Fronsac | last post: by
3 posts views Thread by Bruce D | last post: by
5 posts views Thread by Pavils Jurjans | last post: by
1 post views Thread by sandy | last post: by
3 posts views Thread by Adam Sandler | last post: by
3 posts views Thread by samtilden | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.