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

  • Home
  • SEARCH
  • 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 6152959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:00:41+00:00 2026-05-23T20:00:41+00:00

I experience strange behavior of sockets in Python (3.2). Client connects to my application

  • 0

I experience strange behavior of sockets in Python (3.2). Client connects to my application using Flash. Most of the time there is nothing unusual but sometimes python crashes in a way that should not have taken place – enter into infinite loops. Below I attach to the loop code and error message in the log. Python hang on bytesRecived = sock.recv(64) and receive b'' witch is visible in log.

code:

try:
    buff = ''
    allBytesRecived = []
    timeout = sock.gettimeout()
    sock.settimeout(10.0)
    tries = 0
    while len(buff) < 64 and tries < 64:
        tries += 1
        bytesRecived = sock.recv(64)
        allBytesRecived.append(bytesRecived)
        comm = str(bytesRecived, config.encoding)
        buff += comm

        #flash connection and his strage security policy
        if buff[:24] == config.flash.policy_request:
            cross = open(config.flash.crossdomain,'rb').read()
            cross+=b'\x00' #end string
            sock.send(cross);
            raise FlashCrossdomainException()

    if len(buff) < 64:
        logger.critical('Hanged! buff=%s bytes=%s timeout=%s' % (repr(buff), repr(allBytesRecived), repr(sock.gettimeout())))
        raise InvalidSessionException('Unknown error')
    sock.settimeout(timeout)

except FlashCrossdomainException as e:
    raise e
except socket.timeout:
    raise InvalidSessionException('Timeout on signing in to system')
except socket.error as e:
    logger.exception(e)
    raise InvalidSessionException('Unknown IO error')
except Exception as e:
    logger.exception(e)
    raise InvalidSessionException('Unknown error')

log error:

CRITICAL: Hanged! buff='' bytes=[b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b''] timeout=10.0
  • 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-23T20:00:42+00:00Added an answer on May 23, 2026 at 8:00 pm

    python’s socket module closely matches the BSD socket API.

    when the remote side of a socket (here, your flash client) is closed, the recv() call on the local side (here, your python server) will return an empty string (''). there is no need to continue processing, since the client won’t send anything more: the channel is closed.

    on the other hand, since your socket is non-blocking, if a socket timeout occurs because the client does not send any data within the specified time limit (10 seconds), then the recv() call will raise a socket.timeout exception, which you can catch and process accordingly.

    you should add a test after the recv() call:

    bytesRecived = sock.recv(64)
    if not len(bytesRecived):
        raise InvalidSessionException('connection reset')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using a SortedDictonary(Of String, String) in my application, and I experience a strange
There is very strange assembly reference problem and loading problem I experience with my
Hi I experience a strange phenomena. I have a Java application that queries DB
I experience a strange behavior in Perl while trying to decode a Unicode JSON
I experience strange memory leak in computation expensive content-based image retrieval (CBIR) .NET application
I am experiencing a strange behavior with my android application when dealing with a
Recently, I started to experience strange behaviour in JBOss 4.0.5 JSP application. The JSP
I've experienced rather strange behavior of JSTL forEach tag. I have some bean called
My experience with application servers is limited to some basic servlet coding, so I
I experience the following problem while using legacy VC6. I just cann't switch to

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.