Is this possible

T

Theo James

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
 
J

Joe Smith

Theo said:
(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
 

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

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top