The overall design is not quite right. I cannot see the reason why Tk is involved here, at least base what you presented.

Now under this design, your program only accepts connections when fileevent is fired, which I believe is not what you want, as most likely the client comes any time it wishes. This shall really be a simple socket server side program without Tk.

When your program reaches that line accept socket connection, it just hangs until a client comes, this is not what should happen to a GUI application. This makes the person sitting before the computer really frustrated (at least when I was trying to play with your code).

Multi-threading might help you (one the other hand, most likely you would need multi-thread any way, or other similar technologies, for a socket server that expects multiple clients at a single given time), but still better reconsider whether Tk is needed.


In reply to Re: Tk & Socket: Tk::Error: fileno not same for read X and write Y by pg
in thread Tk & Socket: Tk::Error: fileno not same for read X and write Y by Anonymous Monk

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.