473,385 Members | 2,269 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Connection acception with confirmation


Hi, i'm new in Python and i'm trying to write some server which can
confirm connection from client.
Here is a part of code:

import sys
import threading
from socket import *

class TelGUI(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)

def run(self):
s = socket(AF_INET, SOCK_STREAM)
s.bind(('',8900))
s.listen(5)
while 1:
client,addr = s.accept()
print addr
print "Or u want to accept connection from this host? [y/n]"
opt = sys.stdin.read(1)
if opt == 'y':
#establish
else: s.close() #reject

def main():
app = TelGUI()
app.start()

print "Menu"
while 1:
#some menu operations
op = sys.stdin.read(1)
if op == 'x':
break

if __name__ == "__main__":
main()

maybe someone have some ideas how to block first stdin in main
function and get stdin from the thread when here is a new connection?
Thanks

May 29 '07 #1
1 1250
no`name` wrote in news:11**********************@j4g2000prf.googlegro ups.com
in comp.lang.python:
maybe someone have some ideas how to block first stdin in main
function and get stdin from the thread when here is a new connection?
No, but you could instead use a Queue:

http://docs.python.org/lib/module-Queue.html

so that your main thread reads stdin and then uses an instance
of Queue to post the 'y's and 'n's it recives to your server
thread.

Rob.
--
http://www.victim-prime.dsl.pipex.com/
May 29 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Nedu N | last post by:
Hi, I want to have confirmation(Yes/No) on a button of the webform in which there are many validation controls. I want all the validation controls to be triggered first and then Yes/No...
5
by: Zlatko Matić | last post by:
Hello. In ODBC Data Source Administrator, there is a tab "Connection Pooling" and option "PerfMon" Enable/Disable. Could someone explain the meaning of the option and how it reflects to Access...
2
by: bienwell | last post by:
Hi all, I still have a problem when using Confirmation box in ASP.NET program. I need to get the value return of YES or NO from confirmation box in Sub function of VB program to do some tasks....
4
by: Marcus | last post by:
Hello, Whenever the PHP documentation references the optional link_identifier parameter in many mysql related functions (such as mysql_query, mysql_insert_id, etc.), it says: "The MySQL...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.