Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old January 26th, 2004, 04:34 PM
theperfectsoup theperfectsoup is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 35 theperfectsoup User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Stupid IO question

So I'm in the middle of writing a decentralized file-sharing program in Python. So far I've written code to manage connections to users, maintain a routing table, and send/receive data. To make sure all this code works, I'd first like to use it to make a chat program. A very basic one.

Basically, my question is if I can do a chat program using just a prompt, and no fancy GUI? I expect it would use two threads: The first would wait for a command from the user (of the form something like "<person to message> <message>"). The second would be responsible for sending messages you create and receiving messages for you. But it's also responsible for routing messages passing through you (since it is a decentralized network, messages may pass through you that are not intended for you -- your job is simply to pass them along so that they reach their destinations), so this thread must never sleep. So even while the first thread is waiting for user input, this thread must be active, enabling communication between users.

Now say this second thread, which sends and receives messages, receives a message intended for the user. It needs to display it to the screen -- but would this interfere with the first thread, which is waiting for user input? What if the client received a message and chose to display it to the screen while the user is typing in a message to send to another user? The result could be ugly. Any way to avoid this interference?

The obvious solution is a GUI... One window, two text boxes -- one in which you can type messages to send, and one which displays messages you receive. But in all honesty I don't have much time to learn wxPython right now (I will in a week or so...) -- unless anyone can point me to a, say, really skimpy wxPython tutorial

Sorry if this post is so longwinded. Kinda tired.

- tps

Reply With Quote
  #2  
Old January 26th, 2004, 04:39 PM
d34thm0nk3y d34thm0nk3y is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 3 d34thm0nk3y User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
If all you are doing this for is a test of the communications, why don't you just write the recieved text to a text file? You can just keep reloading it to see when you get data.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Stupid IO question


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway