C source code for simple POP server

Discussion in 'C Programming' started by meATprivacyDOTnet, Apr 1, 2005.

  1. Hi,

    I am trying to learn some C programming language and network programming
    on Linux by myself.

    I am looking for the the source code of a simple POP server in order to
    get a better understanding on how to network functions work.

    Even a non-working explame would be great.

    Do you where I can find it?

    I am not looking for a full-blown POP server (e.g. Courier Mail Server),
    since the source code would be too complex for me (at least for now).

    Thanks a lot.
     
    meATprivacyDOTnet, Apr 1, 2005
    #1
    1. Advertising

  2. meATprivacyDOTnet <> writes:

    > Hi,
    >
    > I am trying to learn some C programming language and network
    > programming on Linux by myself.
    >
    > I am looking for the the source code of a simple POP server in order
    > to get a better understanding on how to network functions work.
    >
    > Even a non-working explame would be great.
    >
    > Do you where I can find it?
    >
    > I am not looking for a full-blown POP server (e.g. Courier Mail
    > Server), since the source code would be too complex for me (at least
    > for now).
    >
    > Thanks a lot.



    Ok, here is a not full-blown POP server. If it's too simple for you
    try the sources of qpopper.

    #!/bin/bash
    printf "+OK POP3 $(hostname -f) v7.64 server ready\r\n"

    exit=0
    while [ $exit = 0 ] ; do
    read key rest ; key=${key:0:4}
    case "$key" in
    USER|user)
    printf -- "+OK User name accepted, password please\r\n"
    exit=1
    ;;
    QUIT|quit)
    printf -- "+OK Sayonara\r\n"
    exit 0
    ;;
    *)
    printf -- "-ERR Unknown AUTHORIZATION state command\r\n"
    ;;
    esac
    done

    exit=0
    while [ $exit = 0 ] ; do
    read key rest ; key=${key:0:4}
    case "$key" in
    PASS|pass)
    printf -- "+OK Mailbox open, 0 messages\r\n"
    exit=1
    ;;
    QUIT|quit)
    printf -- "+OK Sayonara\r\n"
    exit 0
    ;;
    *)
    printf -- "-ERR Unknown command\r\n"
    ;;
    esac
    done

    while true ; do
    read key rest ; key=${key:0:4}
    case "$key" in
    LIST|list)
    printf -- "+OK Mailbox scan listing follows\r\n.\r\n"
    ;;
    QUIT|quit)
    printf -- "+OK Sayonara\r\n"
    exit 0
    ;;
    *)
    printf -- "-ERR Unknown command\r\n"
    ;;
    esac
    done


    --
    __Pascal Bourguignon__ http://www.informatimago.com/
    Our enemies are innovative and resourceful, and so are we. They never
    stop thinking about new ways to harm our country and our people, and
    neither do we. -- Georges W. Bush
     
    Pascal Bourguignon, Apr 1, 2005
    #2
    1. Advertising

  3. Pascal Bourguignon <> writes:

    > printf "+OK POP3 $(hostname -f) v7.64 server ready\r\n"


    I like your pop3 server, but must point that the above would cause havoc on
    your computer if you are _not_ running Linux. E.g. on Solaris

    % hostname -f
    uname: error in setting name: Not owner

    or

    # hostname
    lokrum
    # hostname -f
    # hostname
    -f
    #

    That beat us once when a Linux educated system administrator (which uses
    hostname -s in his .profile) logged on to our NIS server and tried to
    update and push the NIS changes...

    Bye, Dragan

    --
    Dragan Cvetkovic,

    To be or not to be is true. G. Boole No it isn't. L. E. J. Brouwer

    !!! Sender/From address is bogus. Use reply-to one !!!
     
    Dragan Cvetkovic, Apr 1, 2005
    #3
  4. In comp.lang.c Pascal Bourguignon <> wrote:

    > Ok, here is a not full-blown POP server. If it's too simple for you
    > try the sources of qpopper.


    Please remove comp.lang.c from the crosspost list for this thread;
    it isn't topical here. Thanks.

    --
    Christopher Benson-Manica | I *should* know what I'm talking about - if I
    ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
     
    Christopher Benson-Manica, Apr 1, 2005
    #4
  5. meATprivacyDOTnet

    CBFalconer Guest

    Pascal Bourguignon wrote:
    > meATprivacyDOTnet <> writes:
    >
    > > I am trying to learn some C programming language and network
    > > programming on Linux by myself.

    >

    .... snip ...
    >
    > Ok, here is a not full-blown POP server. If it's too simple for
    > you try the sources of qpopper.
    >
    > #!/bin/bash
    > printf "+OK POP3 $(hostname -f) v7.64 server ready\r\n"
    >
    > exit=0
    > while [ $exit = 0 ] ; do
    > read key rest ; key=${key:0:4}
    > case "$key" in
    > USER|user)
    > printf -- "+OK User name accepted, password please\r\n"
    > exit=1
    > ;;
    > QUIT|quit)
    > printf -- "+OK Sayonara\r\n"
    > exit 0
    > ;;
    > *)
    > printf -- "-ERR Unknown AUTHORIZATION state command\r\n"
    > ;;
    > esac
    > done


    By no stretch of the imagination is that C, and thus it is OT on
    c.l.c. Follow-ups set.

    --
    Some useful references about C:
    <http://www.ungerhu.com/jxh/clc.welcome.txt>
    <http://www.eskimo.com/~scs/C-faq/top.html>
    <http://benpfaff.org/writings/clc/off-topic.html>
    <http://anubis.dkuug.dk/jtc1/sc22/wg14/www/docs/n869/> (C99)
    <http://www.dinkumware.com/refxc.html> (C-library}
    <http://gcc.gnu.org/onlinedocs/> (GNU docs)
     
    CBFalconer, Apr 1, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    8,587
    Randy Webb
    Feb 4, 2006
  2. Bone Ur
    Replies:
    4
    Views:
    415
    Bone Ur
    Dec 19, 2007
  3. Chris Davoli

    Tool Tip pop up - pop up time is too short

    Chris Davoli, Feb 24, 2009, in forum: ASP .Net
    Replies:
    1
    Views:
    495
    Lee Atkinson
    Feb 24, 2009
  4. samppi
    Replies:
    27
    Views:
    530
    David A. Black
    Dec 5, 2007
  5. Replies:
    2
    Views:
    155
    Randy Webb
    Feb 4, 2006
Loading...

Share This Page