sockets giving me gray hairs. server keeps dying

Discussion in 'Perl Misc' started by lekonna, Mar 28, 2008.

  1. lekonna

    lekonna Guest

    Hi guys,
    i'm having bit of a hard time getting my very simple multiplexing
    socket server staying alive. It keeps exiting without giving any
    messages, and since i'm running the bugger in while(1) loop i don't
    quite get why the heck it does that.

    Its a very basic echo server with some added features for keeping
    track of users. Basicly i wanted to learn how to use sockets in flash
    and needed something to echo the poo that i send back to me so i came
    up with this quick and dirty solution. Now unfortunately it seems that
    the trusty old work-horse perl keeps dying on me.

    Heres the link to attachr with syntax highlighted version of the
    server implementation.
    http://attachr.com/10605

    very basic server with some ugly xml hacks in it.

    Is there a way to enable some sort of debug info on what actually goes
    wrong?

    Br,
    Lekonna
    lekonna, Mar 28, 2008
    #1
    1. Advertising

  2. lekonna

    lekonna Guest

    On Mar 28, 9:55 am, lekonna <> wrote:
    > Hi guys,
    > i'm having bit of a hard time getting my very simple multiplexing
    > socket server staying alive. It keeps exiting without giving any
    > messages, and since i'm running the bugger in while(1) loop i don't
    > quite get why the heck it does that.
    >
    > Its a very basic echo server with some added features for keeping
    > track of users. Basicly i wanted to learn how to use sockets in flash
    > and needed something to echo the poo that i send back to me so i came
    > up with this quick and dirty solution. Now unfortunately it seems that
    > the trusty old work-horse perl keeps dying on me.
    >
    > Heres the link to attachr with syntax highlighted version of the
    > server implementation.http://attachr.com/10605
    >
    > very basic server with some ugly xml hacks in it.
    >
    > Is there a way to enable some sort of debug info on what actually goes
    > wrong?
    >
    > Br,
    > Lekonna


    some added specs, i ran it on 64 bit rhel 5.1
    with perl servscript.pl 61003 > log.txt
    lekonna, Mar 28, 2008
    #2
    1. Advertising

  3. lekonna

    lekonna Guest

    On Mar 29, 6:42 am, fishfry <> wrote:
    > In article
    > <>,
    >
    > lekonna <> wrote:
    > > Hi guys,
    > > i'm having bit of a hard time getting my very simple multiplexing
    > > socket server staying alive. It keeps exiting without giving any
    > > messages, and since i'm running the bugger in while(1) loop i don't
    > > quite get why the heck it does that.

    >
    > One thing you can do any time a program is "dying for no reason," [which
    > of course really means, dying for some reason that we don't yet
    > understand :)] is to declare a DIE handler, and in the handler, write a
    > log message and a stack trace.
    >
    > Secondly, in the same vein, your program should already be copiously
    > sprinkled with log messages, saying "I'm doing this," and, "I'm getting
    > ready to do that." Of course you will disable those messages when you
    > roll your code to production; but during development, and especially
    > during EARLY development, they are invaluable. If you had a lot of log
    > messages in your code, you'd know the last thing your server did before
    > it died.
    >
    > > Its a very basic echo server with some added features for keeping
    > > track of users. Basicly i wanted to learn how to use sockets in flash
    > > and needed something to echo the poo that i send back to me so i came
    > > up with this quick and dirty solution. Now unfortunately it seems that
    > > the trusty old work-horse perl keeps dying on me.

    >
    > One thing I truly know in this world is that sockets work perfectly well
    > in Perl. I'm going to go way out on a limb here and say that the problem
    > is probably in your code :)
    >
    > > Heres the link to attachr with syntax highlighted version of the
    > > server implementation.
    > >http://attachr.com/10605

    >
    > > very basic server with some ugly xml hacks in it.

    >
    > > Is there a way to enable some sort of debug info on what actually goes
    > > wrong?

    >
    > I didn't look at your code. But if you take my suggestions to write log
    > messages before and after every interesting thing your program does
    > (startup, init, creating/opening/connecting sockets, etc.); and
    > implementing DIE and WARN handlers, you will soon see what's going on.
    > The idea is to equip your program with the means to debug itself.
    >
    > One more thing that comes to mind is that people learning to write
    > servers often have trouble with the logic of handling a connection
    > request using the accept() function. To service a connection request you
    > have to fork a child process to handle that client; or you have to
    > handle the client yourself, managing multiple sockets: the listening
    > socket, on which you receive connection requests; and one for each
    > connected client. Typically you need to use non-blocking sockets in
    > conjunction with the select() call. [And note that "select" is very
    > unfortunately overloaded in Perl to a totally different function that
    > has the exact same name but has nothing to do with it!]
    >
    > It wouldn't hurt to review your accept() logic.
    >
    > Hope this helps.


    Thanks for the reply, actually this implementation isn't a multi
    threading one, wanted to try out an single threaded version for
    change. the thing is that on my windows machine the server runs
    smoothly but dies without an explanation every now and then on the
    linux 64bit machine.

    Since there are no exit points inside the while true loop and no error
    messages are output i can only phantom that it is some kind of bug in
    the actual library i'm using itself. browsed quickly through the 5.8.8
    x86_64-linux-thread-multi/IO lib but couldn't find a way to enable any
    more debug messages as it is.

    This is a tricky one, still no solution. I do believe the problem is
    in my logic but seem to be unable to find more info on where we
    actually exited from.
    lekonna, Apr 2, 2008
    #3
    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. Steve Letford

    session keeps dying?

    Steve Letford, Aug 5, 2003, in forum: ASP .Net
    Replies:
    8
    Views:
    423
  2. Krapul
    Replies:
    2
    Views:
    302
  3. sixteenmillion

    The giving that keeps on giving

    sixteenmillion, Nov 19, 2007, in forum: C Programming
    Replies:
    0
    Views:
    425
    sixteenmillion
    Nov 19, 2007
  4. ech0
    Replies:
    0
    Views:
    1,794
  5. rajmgopal

    Image Button when clicked displays cross-hairs

    rajmgopal, Oct 27, 2006, in forum: ASP .Net Mobile
    Replies:
    0
    Views:
    717
    rajmgopal
    Oct 27, 2006
Loading...

Share This Page