Is this possible

Discussion in 'Perl' started by Theo James, Sep 13, 2004.

  1. Theo James

    Theo James Guest

    I am a newbie perl programmer and I have an idea for a perl program,
    but I want to know if it is possible before I attempt to write it.
    Here is what I need:

    I have a client, talking to my server via TCP/IP to port 1234. The
    client is creating many seperate conversations that are a simple
    request/response pairing. All requests from the client go to port
    1234. Here is how I would like it to flow:

    (main loop)
    Server.pl accepts connection on port 1234 ->
    locks port 1234 from any other new connection ->
    redirects conversation to lesser know port (ex. 2345) ->
    calls subserver.pl on port 2345 to handle request response
    conversation

    as soon as Server.pl fires off subserver.pl ->
    unblock port 1234 and allow another connection (main loop)->

    subserver.pl handles all communications with client and upon
    completion (or time out) imports Server.pl that port 2345 is avilabile
    for communication and then dies (or optionally wait for Server.pl to
    send another session to it).


    I already know how to handle this conversation without multiple
    threads. Everything I've read out there seems to tell me that this is
    hard or impossible. Can this be done? If so, is this design the best
    what to handle it? If so, can you give me the main functions I should
    look into? If not, can you point me in a different direction (please,
    not C!!!)

    Any help would greatly be appreicated!

    --Theo James
     
    Theo James, Sep 13, 2004
    #1
    1. Advertising

  2. Theo James

    Joe Smith Guest

    Theo James wrote:

    > (main loop)
    > Server.pl accepts connection on port 1234 ->


    Server opens a socket on port 1234.
    (main loop)
    Server accepts incoming connection.

    > locks port 1234 from any other new connection ->


    Not needed.

    > redirects conversation to lesser know port (ex. 2345) ->
    > calls subserver.pl on port 2345 to handle request response
    > conversation
    > as soon as Server.pl fires off subserver.pl ->
    > unblock port 1234 and allow another connection (main loop)->


    Server decides on a suitable port, forks a child to listen
    on that port. If the child creation is successful, send
    the port number back on the original socket and close the socket.
    Go back to main loop.

    > subserver.pl handles all communications with client and upon
    > completion (or time out) imports Server.pl that port 2345 is avilabile
    > for communication and then dies (or optionally wait for Server.pl to
    > send another session to it).


    Server uses $SIG{CHILD} and wait() to determine which fork has
    terminated.

    > Can this be done?


    Yes. After you've written a little bit of your servers and client,
    if you have any concrete questions, post them to the comp.lang.perl.misc
    newsgroup (not here at comp.lang.perl).
    -Joe
     
    Joe Smith, Sep 15, 2004
    #2
    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. Michael Giagnocavo [MVP]

    Re: Is it possible....

    Michael Giagnocavo [MVP], Jun 28, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    1,225
    Michael Giagnocavo [MVP]
    Jun 28, 2003
  2. Ekkehard Kraemer

    Development on 98 possible at all?

    Ekkehard Kraemer, Sep 13, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    437
    Dino Chiesa [Microsoft]
    Sep 22, 2003
  3. Markus
    Replies:
    1
    Views:
    513
    Markus
    Nov 22, 2005
  4. Replies:
    4
    Views:
    308
    Kenny McCormack
    Feb 21, 2006
  5. Replies:
    10
    Views:
    501
    Chris Gonnerman
    Dec 14, 2007
Loading...

Share This Page