Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ Programming
➜ General
➜ UDP - Tutorial/Manual, anyone ?
UDP - Tutorial/Manual, anyone ?
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Alca
(20 posts) Bio
|
Date
| Wed 18 Jun 2008 09:23 PM (UTC) |
Message
| Oki, not sure if this belongs here, but here goes anyway...
I've been toying around with Nick's Status Bar thingy, and I love it. I love it so much, that I want to be able to code stuff like this myself.
Now, the only coding language I have some experience with is Python.
My questions:
1) Is it possible to write a comparable program in Python ?
2) If it is, could someone link me to a decent UDP manual/tutorial ?
My 'ultimate' goal would be to have a frame with buttons that would send messages to MUSHclient. Since MUSH comes with UdpListen, I only need to implement a way to send packages using my program.
Any help or advice is most welcome ! Also, if anyone would think this is infeasible or too hard to accomplish, speak up. I already waste enough of my time on games ^^ | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #1 on Wed 18 Jun 2008 10:37 PM (UTC) Amended on Wed 18 Jun 2008 10:38 PM (UTC) by Nick Gammon
|
Message
| I had forgotten about UdpListen. :)
I don't know enough Python to answer your question, sorry, but I can demonstrate how to handle the UDP packets at the MUSHclient end.
The small plugin below shows how to use UdpListen. You need to specify an address to listen to (or 0.0.0.0 for all addresses), and a port to listen to. Finally you specify the name of a script in your plugin. The script will receive any UDP packets addressed to that port.
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Thursday, June 19, 2008, 8:29 AM -->
<!-- MuClient version 4.27 -->
<!-- Plugin "UDPlisten_demo" generated by Plugin Wizard -->
<muclient>
<plugin
name="UDPlisten_demo"
author="Nick Gammon"
id="2d536fbbcfe2aed9d8872aec"
language="Lua"
purpose="Shows how to use UdpListen"
date_written="2008-06-19 08:27:07"
requires="4.00"
version="1.0"
>
</plugin>
<!-- Script -->
<script>
<![CDATA[
function listener (s)
ColourNote ("white", "blue", "Got UDP packet: " .. s)
end -- listener
require "check"
check (UdpListen ("0.0.0.0", 4112, "listener"))
]]>
</script>
</muclient>
To test it I used UDPSend:
/UdpSend ("127.0.0.1", 4112, "Hi there") --> Got UDP packet: Hi there
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Worstje
Netherlands (899 posts) Bio
|
Date
| Reply #2 on Thu 19 Jun 2008 05:39 AM (UTC) Amended on Thu 19 Jun 2008 05:40 AM (UTC) by Worstje
|
Message
| Python can easily do what you want it to do. I hope I'm understanding right that you want to have the entire graphical application be written in Python, otherwise please ignore this post. :)
wxPython is a Pythonwrapper for an often-used graphical toolkit known as wxWidgets. It's fast and supported on many different platforms. Alternatively, you could use TK (or was it TCL that does GUIs? I forgot!) which comes with Python, but it isn't pretty and considered to be outdated for as far frameworks go (or so I've read). Link: http://www.wxpython.org/
For as far using UDP in Python goes... there's the socket module for that. It's supported on pretty much every platform, too. You can find a very comprehensive manual at (1). However, that manual is a bit too general and extensive and doesn't go into the details about udp. You can find more examples at (2).
(1) - http://docs.python.org/dev/library/socket.html?highlight=udp
(2) - http://www.evolt.org/article/Socket_Programming_in_Python/17/60276/
Good luck, and please ask more questions as they arise. :) | Top |
|
Posted by
| Alca
(20 posts) Bio
|
Date
| Reply #3 on Thu 19 Jun 2008 10:38 AM (UTC) |
Message
| Yes, I do want my program to be written solely in Python.
Already got wxPython (way more user-friendly), been making my own doodles and hangman games for Python practice for some time now, so I think I grasp the basics about making decent frames.
I didn't know there was a module for stuff like this in Python... Should've known though, it's got modules for everything.
You two answered my questions prefectly really ^^ From here, I'll try to get things working, and I'll let you know should I succeed.
Thanks for the answers, the links, and the plugin! | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
14,047 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top