C source code for simple POP server

  • Thread starter meATprivacyDOTnet
  • Start date
M

meATprivacyDOTnet

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.
 
P

Pascal Bourguignon

meATprivacyDOTnet said:
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
 
D

Dragan Cvetkovic

Pascal Bourguignon said:
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 !!!
 
C

Christopher Benson-Manica

In comp.lang.c Pascal Bourguignon said:
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.
 
C

CBFalconer

Pascal said:
meATprivacyDOTnet said:
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)
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top