Hello, After a long time not programming in perl I recently tried to write somesthing new. I tried to make a server in perl using sockets. This is all fine, but I want to put some of the code in differen Modules, and this is where the problem starts. Part of the code:
while (($Timeout eq "false") && accept(Client, Server)) { #Server may run and a connection to a client has been found Messages::PrintToLog("Client Connected\n"); my $clientHandle = getpeername (Client) or print "Could not id +entify Client: $!\n"; my ($port, $iaddr) = unpack_sockaddr_in($clientHandle); my $clientIP = inet_ntoa($iaddr); Messages::PrintToLog("Client IP: $clientIP \n"); # Check which branch to go my $answer = <Client>; if ($answer eq "AdminUserLogin\n") { print Client "test"; AdminFunctions::MainCall($clientHandle); #$Timeout = "true"; } elsif($answer eq "ShutDown\n") { #DEBUG ONLY $Timeout = "true"; } Messages::PrintToLog("Got something from the Client: $answer") +; Messages::PrintToLog("Closing Client.\n"); close Client; } Messages::PrintToLog("Closing Server.\n"); close Server;
The problem is the line: AdminFunctions::MainCall($clientHandle); I want to put the client in the module, so that part of the communication is in this case in the "AdminFunctions.pm". in the Module for example the MainCall Function is:
sub MainCall { $ClientHandle = shift @_; Messages::PrintToLog("Admin: MainCall"); print $ClientHandle "Testing"; my $Answer = <$ClientHandle>; #some more function calls }
The program runs until it hits the line: "print $clientHandle" after that no error message is displayed and the program stops. How could i relaize this problem? What are my faults? I hope my english is not as bad as I think, its been a long time since I wrote a text in english (which is not my native language) regards Streen Edit: Repasted the code for better reading, sorry it was so unreadable

In reply to Socket Client to Module by Streen

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.