Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old November 20th, 2000, 02:31 PM
basim basim is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2000
Posts: 0 basim User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to basim
Hi all.

I have a dear question to ask. This topic involves sockets, pipes, fork and daemon processes. I will start by trying to explain the sceneario to the best that I can. I have a server and a "worker".

Server: daemon process responsible for handling new socket connections and message passing between the worker and from other clients.

Worker: daemon process responsible for accessing external networks using sockets and
communicating information from those networks to the server.

So here is the scenario. The server accepts conections. If a new client connects, then I create a pipe to the worker.

open ($MYPIPE[$IDX], "| worker");

this works fine.

Now in the worker process, it connects to a remote network, logs on and waits for events.
I have set up the worker to only accept reading from STDIN based on the first event received from the external network. I do this by forking a process and while(1) read from standard IN.

$pid = fork();
if ($pid == 0) {
while(1) {
#read block
$input = <STDIN>;
chomp($input);
#then i repley and create a message to be # sent to the server
$IpcMsg = &reply( $conn, $from, input);
#call create and connect to server
$MSWSD = &CreateAndConnectSD;
# write to socket the message
print $MSWSD "$IpcMsgn"
# flush the pipe
&flushSD ( $MSWSD );
&closeSD ( $MSWSD );
$input = '';
} #endwhile
exit;
}

again this works fine if i was using this process as a standalone, IE without the server.

So now that i have created a pipe to "worker" i want to write some contents to the pipe so it can relate the message to the external network. In the server, I have:

select( $MYPIPE[$IDX] );
# you go into write block if you don't have n , STDIN doesn't flush in worker
print "$msg[$MSGCONTENT]n" | | warn("nUserMSG: couldn't write to work:$msg[$MSGCONTENT]nSysError $!");
select (STDOUT); #restore STDOUT

now my problem is when i do this, the worker will respond correctly in everything above except that the thread will go into an infinite loop ignoring the read from STDIN the second, third etc time. and plus it sends the same message the was first in the STDIN buffer.

I anybody has any suggestions, comments or anything else i'm ready for discussion

Thanks in advance

Basim

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > Calling all Perl Gurus


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway