Alice Community  

Go Back   Alice Community > Alice 2 > Works-In-Progress

Reply
 
Thread Tools Display Modes
Server and client (nonblocking) in Python
Old
JanOonk
Guest
 
Status:
Posts: n/a
Default Server and client (nonblocking) in Python - 09-14-2007, 04:36 AM

Here's an working example of a nonblocking server/client written in Python. I was hoping that I could use this code in Alice but unfortunately Jython 2.1 (Java implementation of Python) is used which doesn't support nonblocking mode of sockets.

See also my other post http://www.alice.org/community/showthread.php?t=917

So my question remains how can I get this working in Alice? I need Jython 2.2. And this version of Jython requires JRE/JVM >1.4.2_13. So how can I update these so Alice can use it? Or do I have to recompile Alice?

Greetings Jan
Attached Files
File Type: zip PythonServerClient.zip (1.4 KB, 765 views)
   
Reply With Quote
Old
DickBaldwin
Guest
 
Status:
Posts: n/a
Default 09-14-2007, 08:23 AM

Oops!

When I responded to your other message, I hadn't seen this one, so now I see why you would want to update the Java JRE in Alice.

I may be wrong, but I doubt that you can (easily) do what you want to do using Alice 2.0. (Previous typo said 3.0)

If I were you, I would try Storytelling Alice first, which incorporates JRE 1.5, to see if you can do what you want to do.

Last edited by DickBaldwin; 09-14-2007 at 06:49 PM. Reason: Corrected Alice version typo.
   
Reply With Quote
Old
JanOonk
Guest
 
Status:
Posts: n/a
Default 09-18-2007, 05:39 AM

I succeeded in making a socketclient and a socketserver in Alice by using threads. I have put the server in a seperate thread and this works great. Except when you start and close the Alice project, you have to restart Alice to run your project again. I think this is because the port is in use by the thread because I didn't stop the thread before closing the project. I have to use a semaphore or flag or something so the thread nows when to stop.

I will post this version, after cleaning up the code, in a few days.
   
Reply With Quote
Old
DickBaldwin
Guest
 
Status:
Posts: n/a
Default 09-18-2007, 08:55 AM

Quote:
Originally Posted by JanOonk View Post
I succeeded in making a socketclient and a socketserver in Alice by using threads. I have put the server in a seperate thread and this works great. Except when you start and close the Alice project, you have to restart Alice to run your project again. I think this is because the port is in use by the thread because I didn't stop the thread before closing the project. I have to use a semaphore or flag or something so the thread nows when to stop.
Hello JanOonk,

I don't want to discourage you from stretching Alice 2.0 to its extreme limits. After all, that is how many advances in computer science have occurred over the years. However, just in case you are new to Alice and to this forum, I might mention that the primary audience for which Alice 2.0 is intended won't have a clue what you are talking about with regard to nonblocking Java servers, threads, socketclients, socketservers, semaphores, etc.

A few instructors who teach a programming course using Alice 2.0 may understand some of what you are talking about but even in the instructor category, that is probably a very limited audience.

Students who do understond those concepts should not be enrolled in a course that uses Alice 2.0 as a teaching vehicle. Rather, they should be enrolled in an Advanced Java course using Java3D or similar courses that use other teaching vehicles such as C++ or C#.

So, congratulations on your success is stretchng Alice 2.0 to its limits, but I suspect that you are talking to an almost empty auditorium.

Just the opinion of one person who is quite possibly totally incorrect and out of line.

Dick Baldwin

Last edited by DickBaldwin; 09-18-2007 at 09:19 AM. Reason: Grammar correction
   
Reply With Quote
Old
DickBaldwin
Guest
 
Status:
Posts: n/a
Default 09-19-2007, 09:51 AM

For the benefit of those who may be considering this approach to Alice programming, I am going to provide the text of a conversation that I had with Randy Pausch a few months ago. The indented material was excerpted from an earlier message of mine by Randy. That material is then followed by his response.

Baldwin

In any event, I recently discovered by accident that to some degree (see http://www.westga.edu/~drocco/alice/) it is possible to incorporate Python scripts into Alice.
...
It strikes me that this might be a way to introduce the requirement for the students to type in some source code and learn to appreciate the rigors of syntax without requiring them to learn a whole new system (such as Visual Studio or Eclipse) and could be an effective counter to the argument that I described above.

Is there any technical information that you can provide regarding the inclusion of Python scripting in Alice 2.0?
Pausch
That's an entirely left-over backdoor entry point (Alice, believe it or not, used to have students typing python code, rather than drag-and-drop). So if it works at all, it's a miracle, but we certainly didn't intend for anybody to use that.... sorry if that's not the answer you wanted :-(

---end of quotation---

I guess that the bottom line is, use the Python scripting capability that exists in Alice 2.0 at your own risk.
   
Reply With Quote
Reply

Thread Tools
Display Modes

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 On
HTML code is Off

Forum Jump



Copyright ©2017, Carnegie Mellon University
Alice 2.x 1999-2012, Alice 3.x 2008-2012, Carnegie Mellon University. All rights reserved.