Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > C source code for simple POP server

Reply
Thread Tools

C source code for simple POP server

 
 
meATprivacyDOTnet
Guest
Posts: n/a
 
      04-01-2005
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.
 
Reply With Quote
 
 
 
 
Pascal Bourguignon
Guest
Posts: n/a
 
      04-01-2005
meATprivacyDOTnet <(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
 
Dragan Cvetkovic
Guest
Posts: n/a
 
      04-01-2005
Pascal Bourguignon <(E-Mail Removed)> 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 !!!
 
Reply With Quote
 
Christopher Benson-Manica
Guest
Posts: n/a
 
      04-01-2005
In comp.lang.c Pascal Bourguignon <(E-Mail Removed)> 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.
 
Reply With Quote
 
CBFalconer
Guest
Posts: n/a
 
      04-01-2005
Pascal Bourguignon wrote:
> meATprivacyDOTnet <(E-Mail Removed)> 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)

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need a simple imap server with pop retriever Atreju Computer Support 7 12-31-2007 12:10 PM
How to do server-side processing and then display pop-up with pop-up blocker enabled domtam@hotmail.com ASP .Net 2 02-04-2006 06:03 PM
How to do server-side processing and then display pop-up with pop-up blocker enabled domtam@hotmail.com Javascript 2 02-04-2006 06:03 PM
pop up prevention problem; for wanted pop ups joe doe Firefox 2 03-03-2005 08:08 AM
Pop-up to Buy Pop-up software William Young Computer Support 4 01-24-2004 12:28 AM



Advertisments