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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:01:20+00:00 2026-06-12T20:01:20+00:00

I am writing a very simple udp socket connection in Python 2.7 The server

  • 0

I am writing a very simple udp socket connection in Python 2.7

The server side is up and running.
I have trouble on the client side.

from socket import *

serverName = '127.0.0.1'
serverPort = 5444
counter = 1;

while counter < 55:
    mySocket = socket(AF_INET,SOCK_DGRAM)

    try:
        mySocket.settimeout(1.0)
        message = raw_input('')
        mySocket.sendto(message,(serverName, serverPort))
        modifiedMessage, serverAddress = mySocket.recvfrom(1024)
    except mySocket.timeout:
        print 'Request timed out!'
        mySocket.close()
    else:   
        print 'Server Response:  '
        print modifiedMessage   

    mySocket.close()

I am getting the following error.
except mySocket.timeout:
AttributeError: ‘_socketobject’ object has no attribute ‘timeout’

I can’t understand how come there is no timeout attribute?!

In fact I am looking at the intelisense and there is no such attribute too.

Any suggestion will be greatly appreciated

  • 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-12T20:01:21+00:00Added an answer on June 12, 2026 at 8:01 pm

    The socket module has a timeout class. Your socket object, mysocket (of type socket.socket), does not have a timeout attribute.

    Try this:

    except timeout:
        print 'Request timed out!'
        mySocket.close()
    

    Note that you should also be careful about using import * in this manner.

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

Sidebar

Related Questions

Writing a test app to emulate PIO lines, I have a very simple Python/Tk
I'm working on writing a very simple client/server application as an excuse to start
I have been writing a very simple slide show pulling photos from flickr and
I'm writing a very simple web service, written in Python and run as CGI
I'm currently writing a very simple JavaFX application which will hopefully display information from
A very simple question: I am writing and running my R scripts using a
I have been learning some Haskell and writing very simple programs. I want to
I'm writing a script to convert very simple function documentation to XML in python.
I am writing an auto update client. It's a very simple app that: 1)
I'm writing very simple application. It is supposed to download files from internet. I

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.