Chapter 44. apis, Standard networking, Enhanced select() – Comtrol eCos User Manual
Page 593: Apis

Chapter 44. APIs
Standard networking
The APIs for the standard networking calls such as
socket()
,
recv()
and so on, are in header files relative to
the top-level include directory, within the standard subdirectories as conventionally found in
/usr/include
. For
example:
install/include/arpa/tftp.h
install/include/netinet/tcpip.h
install/include/sys/socket.h
install/include/sys/socketvar.h
install/include/sys/sockio.h
network.h
at
the
top
level
defines
various
extensions,
for
example
the
API
init_all_network_interfaces(void)
described above. We advise including
network.h
whether you use
these features or not.
In general, using the networking code may require definition of two symbols: _KERNEL and __ECOS. _KERNEL
is not normally required; __ECOS is normally required. So add this to your compile lines for files which use the
network stack:
-D__ECOS
To expand a little, it’s like this because this is a port of a standard distribution external to Red Hat. One goal is
to perturb the sources as little as possible, so that upgrading and maintenance from the external distribution is
simplified. The __ECOS symbol marks out Red Hat’s additions in making the port. The _KERNEL symbol is
traditional UNIX practice: it distinguishes a compilation which is to be linked into the kernel from one which is
part of an application. eCos applications are fully linked, so this distinction does not apply. _KERNEL can however
be used to control the visibility of the internals of the stack, so depending on what features your application uses,
it may or may not be necessary.
The include file
network.h
undefines _KERNEL unconditionally, to provide an application-like compilation en-
vironment. If you were writing code which, for example, enumerates the stack’s internal structures, that is a kernel-
like compilation environment, so you would need to define _KERNEL (in addition to __ECOS) and avoid including
network.h
.
Enhanced Select()
The network stack supports an extension to the standard select semantics which allows all threads that are waiting
to be restarted even if the select conditions are not satisfied.
The standard select() API:
int
489