| | |
Attempting to reconnect socket fails
Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Mar 2008
Posts: 1
Reputation:
Solved Threads: 0
I'm trying to make something that once it is disconnected will automatically try to reconnect. I'll add some more features in later so it doesn't hammer the server but right now I just want to keep it simple and get that part working. The problem is that when I use sock.close I get an error message of
and if I either use shutdown or just go straight to reconnecting I get:
This is what I've got right now:
What am I doing wrong?
•
•
•
•
Bad File Descriptor
•
•
•
•
Transport endpoint is already connected
python Syntax (Toggle Plain Text)
#! /usr/bin/env python import socket, string sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) def doconn(): sock.connect(("localhost", 1234)) def dodiscon(): sock.close() doconn() doconn() while (1): buffer = sock.recv(1024) if not buffer: dodiscon()
What am I doing wrong?
![]() |
Other Threads in the Python Forum
- Previous Thread: Password Storage System.
- Next Thread: Error when converting datestring from one form to another
| Thread Tools | Search this Thread |
Tag cloud for Python
accessdenied apache application argv beginner book change code color dictionary dynamic edit editing enter examples excel file filename float format ftp function gui homework import inches input java keyboard lapse library line lines linux list lists loop microphone mouse movingimageswithpygame mysql newb number numbers numeric output parameters parsing path port prime program programming projects py2exe pygame pyopengl pyqt python random recursion recursive redirect remote reverse rpg scrolledtext search server session simple smtp software sprite ssh statictext string strings syntax table tennis terminal text thread threading time tkinter tlapse trick tuple tutorial ubuntu unicode unit urllib urllib2 variable windows wordgame wxpython





