1

I have written a small Proxy server which listens on the port 25 and does some set of operations.

In case of secure SMTP, i fork a process and let the child process take over for this session.

The thought process was that this child process should be the one who caters to a particular clients requests. If there is another client sending mails (secured) , then i need to fork another process.

But whats happening is that once the child process has processed the clients requests, it keeps on listening, but does not cater to this client. The parent process is already listening on this socket, so forks a new process every time.

How can i handle this situation? if a process has been forked for a client(ip address), then new forking should not happen. The existing child process should handle these requests.

The program is C based and running on linux.

Chief Wiggum
  • 2,784
  • 2
  • 31
  • 44
chingupt
  • 403
  • 2
  • 7
  • 19

1 Answers1

1

Retain the sender's information in the client process. When you receive a new SMTP message then check if the sender is the same as before. If it is, do not fork to a new client.

If this does not answer your question please include the essential parts of your code so we can see where the logical fault might reside.

Flipbed
  • 719
  • 9
  • 18
  • 1
    The part of checking is sender is same or not is to be done by parent process. rt? If its same as before, then i need to forward the req to the child process. How to do that? – chingupt May 15 '13 at 05:49
  • @chingupt: On how to pass a file/socket descriptor from one process to another you might like to read this: http://stackoverflow.com/a/2358843/694576 and/or this http://stackoverflow.com/a/1997642/694576 – alk May 15 '13 at 07:21