Re: Google summer of code



Paolo Amoroso <amoroso@xxxxxxxxx> writes:

Socket API Analysis
http://www.findinglisp.com/blog/2005/12/socket-api-analysis.html

Regarding address representation, I wonder why implementations don't
just wrap the C BSD sockets interface. That is, an address is a pack
of bytes prefixed with an address family. You can always treat the
data as an opaque byte array, and additionally for particular known
address families the implementation provides customized field
accessors. The C interface was designed such that generic address
handling code doesn't have to know address formats. This solves
problems with supporting IPv6, UDP, system-specific protocols etc.

I did this for my language Kogut. An address appears to have fields
family (isomorphic to an integer) and data (a byte array). In addition
addresses appear to have fields which depend on the family. These
fields present data in more convenient formats; they can be used to
access parts of data of an address, or for construction of a new
address. Fields for particular address families include:

* InetFamily - port (integer) and addr (a list of 4 bytes)
* Inet6Family - port (integer), flowInfo (integer),
addr (a list of 16 bytes), scopeId (integer)
* UnixFamily - path (string)

Handlers of fields of particular address families are kept in central
dictionaries, and can be added externally.

The internal representation of an address wraps the C representation,
so it doesn't have to be marshalled when used with socket functions.

Unix provides getaddrinfo() and getnameinfo() for translation of
Internet addresses from/to strings, both in numeric formats and basing
on DNS. On systems which provide these functions, there is no need to
write custom printers and parsers for human-readable IPv4 and IPv6
addresses, and thus IPv6 just works if only the OS supports it.

--
__("< Marcin Kowalczyk
\__/ qrczak@xxxxxxxxxx
^^ http://qrnik.knm.org.pl/~qrczak/
.



Relevant Pages

  • Re: Layout Hell-o
    ... The C standard requires that integral types use a "pure binary ... the representation match the "native" pure binary representation used ... C implementations essentially always do use the native ... integers if the CPU uses big-endian integers. ...
    (comp.lang.cobol)
  • Re: How to extract bytes from long?
    ... >> Implementations are allowed trap negative zero. ... zero" is meaningful in standard C (depending on the representation ... ...which is guaranteed to have an all-ones bit pattern, ...
    (comp.lang.c)
  • Re: what is trap representation?
    ... > of 'trap representation'. ... If the stored value of an object has such a representation ... Some implementations will issue some kind of exception, such as a SIGFPE, ... and therefore not part of standard C. ...
    (comp.lang.c.moderated)
  • Re: (let ((x 1.0)) `#(,x)) [Re: `#2a((1.0))]
    ... > I think the fluke is as folows: Some implementations of backquote are ... > representation of the backquoted expression. ... > through an array, those expressions stay commafied. ...
    (comp.lang.lisp)
  • Re: Network time to C time
    ... the representation, which uses 32 bits for the whole number of seconds ... and 32-bits for the fraction, ... The idea that seconds since 1970 will wrap in 2036 assumes an integer ... represent seconds since 1970; this overflows in 2038. ...
    (comp.lang.c)

Loading