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:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old March 13th, 2004, 01:56 PM
XxChris XxChris is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 217 XxChris User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Chat Server Version 0.1

As you may or may not know, I've been writing a small chat server and chat client. It's not done yet (my todo list is in the file ) but I wanted to post it here for any suggestions. I would appreciate any help on how to make the code 'better'. Thanks in advance.

Btw, I havn't included the client as it is just used for debugging atm.
Attached Files
File Type: txt chatserver.txt (11.6 KB, 790 views)

Reply With Quote
  #2  
Old March 13th, 2004, 02:22 PM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,529 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 19 m 5 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
Thumbs up

Impresive, clean and highly OOP! Looking very good so far . Will have a sit down and read though it a little latter. I'll let you know more then .

Mark.
__________________
programming language development: www.netytan.com Hula


Reply With Quote
  #3  
Old March 13th, 2004, 02:32 PM
Grim Archon's Avatar
Grim Archon Grim Archon is offline
Mini me.
Dev Shed Novice (500 - 999 posts)
 
Join Date: Nov 2003
Location: Cambridge, UK
Posts: 783 Grim Archon User rank is Corporal (100 - 500 Reputation Level)Grim Archon User rank is Corporal (100 - 500 Reputation Level)Grim Archon User rank is Corporal (100 - 500 Reputation Level)Grim Archon User rank is Corporal (100 - 500 Reputation Level)  Folding Points: 1488 Folding Title: Novice Folder
Time spent in forums: 3 Days 2 h 15 m 57 sec
Reputation Power: 7
Send a message via MSN to Grim Archon
Thumbs up This is looking good!

Two thumbs from me:

Any chance to get to client code? I'd like to test your server

Grim
__________________
*** Experimental Python Markup CGI V2 ***

Reply With Quote
  #4  
Old March 13th, 2004, 03:02 PM
XxChris XxChris is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 217 XxChris User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks for the kind words . As for the client, I've attached it here. Hopefuly you can figure it out as it's kind of a mess and uncommented. Sorry I can't say much more now because I'm just heading out!

Btw, my friend is writing a GUI client in Perl and should be done soon.
Attached Files
File Type: txt chatclient.txt (5.5 KB, 496 views)

Reply With Quote
  #5  
Old March 13th, 2004, 03:40 PM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,529 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 19 m 5 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
There was a little problem with your client - port isn't defined. Just check em on this one, the port number should be 50007 right?

Why perl; surly a Python GUI client would be better since the server is Python?

Edit: My bad. The port number should have been supplied though sys.argv... i'm on windows so i just double clicked .

Mark.

Last edited by netytan : March 13th, 2004 at 03:44 PM.

Reply With Quote
  #6  
Old March 13th, 2004, 04:23 PM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,529 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 19 m 5 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
A little lost, i started the server and two clients (both would have the same IP, not sure if that makes a differance but it might explain some things) but i cant get either to echo in the server window or the other client window.

Maybe you could talk us though a simple server-client test?

Mark.

Reply With Quote
  #7  
Old March 13th, 2004, 05:36 PM
XxChris XxChris is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 217 XxChris User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi, I'm at a friends so I'll need to make this quick. You need to specify a port and a nickname at the command line and optionaly an address.

I probably should have documented it a bit better before posting, sorry. But here is a quick tutorial:

From the client:
say <message> to send a global message (like on irc)
pm <name> <message> to send a private message
pmlist to view all your private messages
messages to view normaly messages (from "say")

From the server:

global <message> to send a global message.
dump to view a raw dump of everything sent out


Uhh I can't think of much more atm, but I'll post again tomarrow. I hope this helps for now.

Reply With Quote
  #8  
Old March 14th, 2004, 04:47 AM
xlordt's Avatar
xlordt xlordt is offline
Only the strong survives!!.
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Feb 2003
Location: A World of wonder.
Posts: 5,543 xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)  Folding Points: 108894 Folding Title: Super Ultimate Folder - Level 1Folding Points: 108894 Folding Title: Super Ultimate Folder - Level 1Folding Points: 108894 Folding Title: Super Ultimate Folder - Level 1Folding Points: 108894 Folding Title: Super Ultimate Folder - Level 1Folding Points: 108894 Folding Title: Super Ultimate Folder - Level 1Folding Points: 108894 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 4 Weeks 1 Day 22 h 42 m 5 sec
Reputation Power: 378
Send a message via ICQ to xlordt Send a message via AIM to xlordt Send a message via MSN to xlordt Send a message via Yahoo to xlordt Send a message via Google Talk to xlordt Send a message via Skype to xlordt
Facebook
Im doing the same thing.. except that i will have client & server in one

Reply With Quote
  #9  
Old March 14th, 2004, 09:32 AM
XxChris XxChris is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 217 XxChris User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
That client at the moment isn't really usable for a conversation as you need to type a command to send a message and a command to view your messages. I'll post the Perl client and the new server when they're done. The Perl client will look somewhat like mIRC. We're trying to mimic something like IRC rather than MSN, AIM or Yahoo IM.

Btw, the reason for no Python GUI client is that I havn't found many tutorials for wxPython.

Last edited by XxChris : March 14th, 2004 at 09:35 AM.

Reply With Quote
  #10  
Old March 14th, 2004, 11:07 AM
Grim Archon's Avatar
Grim Archon Grim Archon is offline
Mini me.
Dev Shed Novice (500 - 999 posts)
 
Join Date: Nov 2003
Location: Cambridge, UK
Posts: 783 Grim Archon User rank is Corporal (100 - 500 Reputation Level)Grim Archon User rank is Corporal (100 - 500 Reputation Level)Grim Archon User rank is Corporal (100 - 500 Reputation Level)Grim Archon User rank is Corporal (100 - 500 Reputation Level)  Folding Points: 1488 Folding Title: Novice Folder
Time spent in forums: 3 Days 2 h 15 m 57 sec
Reputation Power: 7
Send a message via MSN to Grim Archon
I keep mentioning Boa, but it does have a tutorial that shows the basics of wxPython from a Boa perspective.

Grim

Reply With Quote
  #11  
Old March 14th, 2004, 11:55 AM
XxChris XxChris is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 217 XxChris User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I'll look into it, thanks . Btw, has anyone had any troubles with the server or client? Is it working properly?

Last edited by XxChris : March 14th, 2004 at 12:20 PM.

Reply With Quote
  #12  
Old March 14th, 2004, 01:29 PM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,529 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 19 m 5 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
If by trouble you mean failure to get it working then you can count me in . For some reason couldn't get the clients to talk with each other, possibly because both the IP addresses are the same but...

Mark.

Reply With Quote
  #13  
Old March 14th, 2004, 01:51 PM
XxChris XxChris is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 217 XxChris User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
@netytan:

The IP addresses won't affect it as the server uses threads and sockets to differenciate between clients. Here is a little tutorial:

Start the server up:

Code:
./chatserver.py 1024


Start two clients up:

Code:
./chatclient.py 1024 Chris
./chatclient.py 1024 Mark


Now, using the server console you should be able to type "users" and see both of those clients:

Code:
[Aurora:python/projects/chat] chris% ./chatserver.py 50007
> users
127.0.0.1       Mark
127.0.0.1       Chris


You can use the "online" command from either client to get the same effect. Now, since it's just a simple text based client (for debugging) you need to use a command to send a message, and another to view messages. Using "say <message>" from either client will send a message. Use "messages" on the opposite client to view it:

Code:
[Aurora:python/projects/chat] chris% ./chatclient.py 50007 Chris
> say Hi, Mark


Code:
[Aurora:python/projects/chat] chris% ./chatclient.py 50007 Mark
> messages
Chris: Hi, Mark


With the "name <newname>" command you can change your name to whatever you like, as long as it isn't used already. You can use the "events" command from the server console to view things like name changes, disconnections or connections.

Code:
[Aurora:python/projects/chat] chris% ./chatclient.py 50007 Chris
> say Hi, Mark
> name christofer
> say I changed my name!


Code:
[Aurora:python/projects/chat] chris% ./chatserver.py 50007
> users
127.0.0.1       Mark
127.0.0.1       Chris
> events
127.0.0.1       Mark    Connected
127.0.0.1       Chris   Connected
127.0.0.1       Chris   Name: christofer


Code:
[Aurora:python/projects/chat] chris% ./chatclient.py 50007 Mark
> messages
Chris: Hi, Mark
> online
Mark
christofer
> messages
Chris: Hi, Mark
christofer: I changed my name!


There is other stuff like private messages ("pm <user> <message>" and "pmlist" to view your PMs), also you can use "dump" from the server console to view everything it has sent out.

Code:
[Aurora:python/projects/chat] chris% ./chatclient.py 50007 Mark
> pm christofer Your confusing me!


Code:
[Aurora:python/projects/chat] chris% ./chatclient.py 50007 Chris
> pmlist
Mark: Your confusing me!
> messages
Chris: Hi, Mark
christofer: I changed my name!


File sending is comming soon . Oh, and "quit" quits the server. The clients don't have any clean way to quit atm (It's not really meant to be used ). I hope this helps!

Last edited by XxChris : March 14th, 2004 at 02:06 PM.

Reply With Quote