Berkeley CSUA MOTD:Entry 39858
Berkeley CSUA MOTD
 
WIKI | FAQ | Tech FAQ
http://csua.com/feed/
2025/07/08 [General] UID:1000 Activity:popular
7/8     

2005/9/24-28 [Computer/SW/OS/FreeBSD, Computer/SW/Languages] UID:39858 Activity:low
9/24    Hi, I'm finding myself having to convert network order
        to host order for uint_16 as follows, is there a cleaner way?
            src = buffer[2];
            src = src << 8;
            src += buffer[1];
        \_ man htons
        \_ Uhm, I don't think your way is even correct.
           1. Do you really mean to use 1-based array indices?
           2. You're always storing the most-significant-byte in the
              position of the least-significant-byte. (Note that this is
              irrelevant to whether your host is big- or little-endian.)
              Simply writing src = buffer[0] << 8 | buffer[1] should be
              sufficient.
              \_ I thought network order was LSB first?  So it should be:
                 src = buffer[1] << 8 | buffer[0]
                 \_ You thought wrong.  Do some homework.
           \_ If you are overlaying a buffer onto the short, that is
              inherently endian-dependent. Use htons, duh.
              \_ He's not overlaying a buffer onto a short.  He's reading it
                 into a buffer first.  When he reads it out of the buffer
                 with shift and bitwise operators, the endianness of the host
                 is irrelevant. (And I'm not suggesting not to use htos, I'm
                 just saying that what he wrote originally was wrong.)
                 \- "is there a cleaner way" ... gee, ya think?
                    if this is for work, have them buy you all the stevens
                    books. if they will only buy you one, probably get
                    STEVENS: Network Programming v1. I have the 2nd ed but
                    I am sure the edition++ is fine if not better eventhough
                    STEVENS -> dead. This is "the standard". oktnx. --psb
                    STEVENS -> dead. Like VAX BSD 4.2/4.3, this is "the
                    standard".  oktnx. --psb
2025/07/08 [General] UID:1000 Activity:popular
7/8     

You may also be interested in these entries...
2012/12/18-2013/1/24 [Computer/SW/Languages/Perl] UID:54561 Activity:nil
12/18   Happy 25th birthday Perl, and FUCK YOU Larry Wall for fucking up
        the computer science formalism that sets back compilers development
        back for at least a decade:
        http://techcrunch.com/2012/12/18/print-happy-25th-birthday-perl
        \_ I tried to learn Perl but was scared away by it.  Maybe scripting
           lanauages have to be like that in order to work well?
	...
2011/2/13-4/20 [Computer/SW/Languages/JavaScript, Computer/SW/Languages, Science/GlobalWarming] UID:54037 Activity:nil
2/13    Prototype based programming/delegation (not the pattern).  anyone
        use this at all in real world?  Does it really solve the problem of
        OOP brittleness?
	...
2011/2/24-4/20 [Computer/SW/Languages/Java] UID:54048 Activity:nil
2/24    Go Programming Language.  Anyone here use it?  It kind of
        reminds me of java-meets python, and well, that is fitting given it's
        a GOOG product.  What is so special about it?
        \_ as I understand it, it's a suitable OOP-y systems language with more
           structure than C, less complexity than C++, and less overhead than
           Java/Python.
	...
2011/3/7-4/20 [Computer/SW/Languages/C_Cplusplus] UID:54056 Activity:nil
3/7     I have a C question.  I have the following source code in two identical
        files t.c and t.cpp:
                #include <stdlib.h>
                int main(int argc, char *argv[]) {
                  const char * const * p1;
                  const char * * p2;
	...
2011/2/5-19 [Computer/SW/Languages/C_Cplusplus] UID:54027 Activity:nil
2/4     random C programming/linker fu question.  If I have
        int main() { printf("%s is at this adddr %p\n", "strlen", strlen); }
        and soda's /proc/sys/kernel/randomize_va_space is 2 (eg; on)
        why is strlen (or any other libc fn) at the same address every time?
        \_ I don't pretend to actually know the right answer to this, but
           could it have something to do with shared libraries?
	...
2010/8/8-9/7 [Computer/SW/Languages/C_Cplusplus, Computer/SW/Languages/Web] UID:53914 Activity:nil
8/8     Trying to make a list of interesting features languages have
        touted as this whole PL field comes around, trying to see if they
        have basis in the culture of the time: feel free to add some/dispute
        1970 C, "portability"
        1980 C++, classes, oop, iterators, streams, functors, templates
             expert systems
	...
2010/2/26-3/30 [Computer/SW/OS/Linux, Industry/Jobs] UID:53727 Activity:nil
2/26    http://www.infoworld.com/d/adventures-in-it/painful-truth-about-age-discrimination-in-tech-209?page=0%2c0
        There are bold programmers, but no old programmers
        \_ This is true, mot ppl i knokw who are older seem to want to "get out
           of programming."  They have kids, they want to do other things.
           \_ There was an article about how programming isn't that rewarding
              as an end game to most normal (non psychologically troubled) folk
	...
2010/3/7-30 [Computer/SW/Languages] UID:53743 Activity:nil
3/7     My sister is graduating soon with a decree in information management.
        She was orignally CS, but couldn't cut the math, so her GPA sucks.
        However, she has had a couple of internships and did fine.  She did
        desktop support at RockYou and is currently doing web programming
        at UC Santa Cruz, but they can't keep her on after graduation.
        Anyone got any jobs?  She wanted to be a network admin, but right now
	...