Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 636071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:28:30+00:00 2026-05-13T20:28:30+00:00

I’ve this little script which does it’s job pretty well but sometimes it tends

  • 0

I’ve this little script which does it’s job pretty well but sometimes it tends to fail. It fails in 2 cases:

  1. with error send: Cannot determine peer address at ./tcp-new.pl line 52

  2. with no output or anything, it just fails to deliver what it got to connected Tcp Client. Usually it happens after I disconnect from server, go home and connect it again. To fix this restart is required and it starts working. Sometimes this problem is followed by problem mentioned in point 1.

Note: it’s not problem when I disconnect and reconnect to it again within short amount of time (unless error nr 1 happens).

So can anyone help me make this code be a bit more stable so I don’t have to restart it every day?

#!/usr/bin/perl
use strict;
use warnings;
use IO::Socket;
use IO::Select;

my $tcp_port = "10008";
my $udp_port = "2099";

my $tcp_socket = IO::Socket::INET->new(
  Listen => SOMAXCONN,  LocalPort => $tcp_port,
  Proto  => 'tcp',      ReuseAddr => 1,
);
my $udp_socket = IO::Socket::INET->new(
  LocalPort => $udp_port, Proto => 'udp',
);

my $read_select  = IO::Select->new();
my $write_select = IO::Select->new();

$read_select->add($tcp_socket);
$read_select->add($udp_socket);

while (1) {
  my @read = $read_select->can_read();

  foreach my $read (@read) {

    if ($read == $tcp_socket) {

        my $new_tcp = $read->accept();
        $write_select->add($new_tcp);

    } elsif ($read == $udp_socket) {

        my $recv_buffer;
        $udp_socket->recv($recv_buffer, 1024, undef);

        my @write = $write_select->can_write();
        foreach my $write (@write) {
            $write->send($recv_buffer);
        }
    }
  }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T20:28:30+00:00Added an answer on May 13, 2026 at 8:28 pm

    The Cannot determine peer address error means that the getpeername() returned false. This probably means that the socket has been closed from the other side, possibly between the can_write() call and the send call. You should probably remove it from the select set and move on.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.