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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T13:36:46+00:00 2026-06-05T13:36:46+00:00

Situation: I have a sendersocket which is bound to localhost UDP port 33100. I

  • 0

Situation:

I have a sendersocket which is bound to localhost UDP port 33100.
I have a receiversocket socket bound to localhost UDP port 33101.

The sender socket sends 4500 bytes of data (the string “hello man” * 500). On the receiver side, I have an epoll object which waits for the EPOLLIN event on the receiversocket. When there’s an event, I do:

while True:
    msg_received = receiver_socket.recv(128)
    if msg_received.decode("UTF-8") == "":
        break
    else:
        print msg_received.decode("UTF-8")

Problem:

The main problem is that I cannot read again after I have read the first 128 bytes of data. The sender side says it sent 4500 bytes of data as expected.

If the sender sends the same 4500 bytes of data again, the EPOLLIN event is registered again and I read the new string. Somehow, the buffer get’s cleared after my first read.

Now even though the sender just sent me 4500 bytes of data, the first recv gives me 128 bytes of data and then nothing is recved after that.

I am probably doing something really stupid so please enlighten me. I want to receive all the 4500 bytes of data.

  • 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-06-05T13:36:47+00:00Added an answer on June 5, 2026 at 1:36 pm

    You should always call recv with 65535 (the maximum size of a UDP packet) if you don’t already know the size of the packet. Otherwise, when you call recv, the entire packet is marked as read and cleared from the buffer, but then only the first 128 bytes are fed to msg_received.

    edit: when(if) you transition to receiving data only across a network, you can use a smaller number for recv, as noted in the Docs

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

Sidebar

Related Questions

I have following situation - Have a MongoService class, which reads host, port, database
Situation: I have an index page which loads pages into it with ajax as
Situation: I have a web application which shows errors and where you can accept
I have such situation: We have a website which code is not hosted on
Situation: I have a C# program which does the following: Generate many files (replacing
[Situation] I have a custom item control which I add to a stack panel
Situation:- I have created a installation setup(local) that returns a URL eg:- ved.test.com which
Situation: I have website which calls WCF Service and i'm trying to understand it..
Situation: I have a Service (also have tried using an Activity ) that sends
SITUATION: I have a python library, which is controlled by git, and bundled with

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.