Share your knowledge at the LQ Wiki.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 02-10-2010, 05:00 PM   #1
Registered: May 2009
Posts: 43

Rep: Reputation: 15
question about python and sockets.. as the accept line() exacutes program hangs

ok so my question here is i wrote a simple chat type like thing to just see if what i read was working.. anyway

on the server side once it hits the
clientsocket, address = serversocket.accept()
pythonwin dosent respond untill i actually connect with the client
its a TCP based socket SOCK_STREAM

it doest the same thing when i do it under linux as well

so i guess im just wonder is it because im using TCP that its hanging? is it waiting for the connection? could this be eliminated using udp or is their a way that i could check if a client was trying to connect and if not exacute more commands and then come back to check again after so long like a compare a count variable in a loop or something
any help is much appreciated
Old 02-14-2010, 02:44 PM   #2
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,571

Rep: Reputation: 180Reputation: 180
You need to make the socket nonblocking. After you have created it, use
And it should work better. Then you need to select() or any other method to find out when the client actually connects.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[python] reading non-blocking sockets with makefile Ephracis Programming 0 02-25-2009 06:22 PM
Simple sockets program question default5 Programming 10 06-11-2008 08:15 AM
Program to forward tcp sockets to unix domain sockets mikepol Linux - Networking 0 09-27-2007 09:49 AM
accept input escape new line monil Programming 12 03-18-2005 12:10 PM
stopping a command-line program from python kernelpanicguy Programming 0 09-08-2003 03:29 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:59 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration