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 7404169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:13:03+00:00 2026-05-29T05:13:03+00:00

I have a TCP Socket beetwen two programs, a C# server and a Perl

  • 0

I have a TCP Socket beetwen two programs, a C# server and a Perl client. The client is supposed to receive an XML stream from the server. The XML file (generated by the C# program) is around 437KB but the client only receives 408KB no matter how big is the buffer. On the client side I use IO::Socket::INET while the server side uses a combination of TcpListener and TcpClient. How can I properly define the buffer on the client side? Right now I am using that code:

# PERL CLIENT
my $socket = new IO::Socket::INET (
    PeerHost => '192.168.*.*',
    PeerPort => '*****',
    Proto => 'tcp'
) or die "Error while creating Socket";
#
# OTHER STUFFS...
#
my $buffer = 500000000; # IT DOESNT SEEM TO USE THAT VALUE AT ALL
$socket->recv($xmlbody, $buffer);


// C# SERVER
// OTHER STUFFS...
byte[] result = encoding.GetBytes(xml);
clientStream.Write(result, 0, result.Length);
clientStream.Flush();
clientStream.Close();
tcpClient.Close();
  • 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-29T05:13:04+00:00Added an answer on May 29, 2026 at 5:13 am

    I never use recv, so I don’t know its quirks. I use sysread.

    sub read_until_eof {
       my ($fh) = @_;
       my $buf = '';
       for (;;) {
          my $rv = sysread($fh, $buf, 64*1024, length($buf))
          die $! if !defined($rv);
          return $buf if !$rv;
       }
    }
    

    If this doesn’t do it, I suggest you use tcpdump to ascertain whether the problem is in the sender, the receiver, or somewhere in between.


    sysread‘s and read‘s “quirks”:

    sysread always returns as soon as bytes bytes available, regardless of how many bytes were requested. That means it returns immediately if bytes are already available when it is called. It will block until a packet comes in otherwise. That means one needs to loop if one wants a specific number of characters.

    In contrast, read waits until the requested number of bytes are available. It only returns then, on EOF or on error.

    read and sysread actually work at the character level, which means you actually specify a number of characters desired, not a number of bytes. Those characters could be bytes, Unicode code points or whatever depending on what IO layer you added to the handle.

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

Sidebar

Related Questions

I have a TCP socket client receiving messages (data) from a server. messages are
I have a tcp socket on which I receive video stream. I want to
I have a simple TCP socket client and server application. They are communicating using
I have a client/server connection over a TCP socket, with the server writing to
I have a class that encapsulates tcp socket communications with a server. For each
I want to open a TCP client socket in Python. Do I have to
I need to write a daemon that supposed to have one TCP socket and
My client application uses a boost::asio::ip::tcp::socket to connect to a remote server. If the
I have a client tcp socket (in c++) that has a loop where it
I have a client TCP socket that writes a few bytes every five seconds,

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.