View Full Version : Socket Object Plugin
Ulrich
04-30-2009, 03:39 PM
Hello,
after some weeks of development, I think that now my new plugin is stable enough to be announced publicly here in the forum. With the help of this object plugin, you can build full featured network-enabled applications with AutoPlay Media Studio. With a few lines of Lua script and by dropping a single socket object on the page, you may build server or client projects, communicate with remote servers, exchange messages, check or send mail, chat, etc. Several example projects are included in the documentation, that were used during the development, to make sure that all functions work, and that no essential functionality is missing. That doesn't mean that the plugin can't get further enhancements - just that right now it already can do a lot.
The plugin ships with documentation in CHM format, which contains links to three example projects, so far. These are the projects:
1. A POP3 client
http://www.mindquake.com.br/files/ams/SNAG-090430-03.jpg
This example will show you how to connect to a remote POP3 mail server, retrieve the number of messages that are currently stored in the mailbox, the size of the mailbox in bytes, and information (sender, subject) of the 12 most recent messages that you received. The screen shows what you should expect to see if you run the demonstration project, and query a spammed mailbox, like mine (which I actually don't monitor at all).
2. A multi-user chat server
http://www.mindquake.com.br/files/ams/SNAG-090430-01.jpg
This example shows a working chat server for a multi-user chat room. I may have a chat server running with the parameters used in this example project, so you should change at least the nickname of the server before trying to run your own instance of it. The server announces itself to the internet and the connection parameters (ip address, port number) may be retrieved by the chat clients using the same nickname.
In other words, I implemented a mechanism that would allow you to host a chat server, even if you are on a dynamic IP address. Upon start, the server will try to announce its nickname, IP address and port on what it is listening, to a public database. The chat client will be able to retrieve these connection informations just by knowing the nickname, which of course should be the same in the server and client project.
Of course, if you run a server on the local network, you shouldn't announce it publicly. And if you are behind a proxy or a firewall, the IP address reported to the database may be wrong. You might to know a bit about NAT, port mapping, etc. if you plan to use this feature in such scenarios.
New messages received from any client are immediately echoed to all connected chat clients, in the same order as they are received. The server interface shows the connected clients (handle number and remote ip address), and offers the possibility to kick (disconnect) users individually.
The server re-publishes itself after 5 hours and 50 minutes, before the initial announcement expires (which happens automatically after 6 hours). If you don't re-validate your nickname, this info will be removed from the public database. Another server will be able to use the same nickname after the expiration. A good reason to use unique nicknames. :)
3. A chat client for the multi-user chat server
http://www.mindquake.com.br/files/ams/SNAG-090430-02.jpg
This is, of course, just a demonstration. You should implement your own protocol, show the chat in a pleasant interface. My intention was not to build the best chat client, but to get the communication working as it should. However, you might want to look at the code of these projects, to see how things were done. If you fire up this demo project, you may be able to connect to the demo chat server from item 2. But I won't keep this running for a long time - you should be able to fire up your own servers with ease.
Well, those are the demo projects currently available. I am going to implement a SMTP client soon, and include it as an additional example, so next you will be able to send mail directly from AutoPlay Media Studio. But give me a few days to gather my breath first.
This is not a free plugin, but you may try it for two weeks, so you can see if it fits your needs without any risk. All info about licensing can be found in the documentation. Finally, you will find a link to download the installer here (http://www.mindquake.com.br/ams-socket.php).
Ulrich
Nice work Ulrich!
This is a very cool plugin. I can't wait to see what people come up with using this one.
mark.
Imagine Programming
04-30-2009, 05:03 PM
that's a ni.... wait wut!?!?! SOCKET!~!!
Thanks Mr. Peters, this is amazing!
**Edit, nice setup aswell.
Dermot
05-01-2009, 12:51 AM
Wow! this is fantastic. Great job.
MicroByte
05-01-2009, 03:05 AM
and about time too!, lol
nice one Ulrich :yes, this means i can do away with my .NET socket lib, and i just know now my boss will have me updateing some of our software products ... i see some overtime coming!
ShadowUK
05-01-2009, 10:44 AM
Oh great, just when I was saving up my money this came along. :(
Looks like I'll have to buy this one though.
reteset
05-01-2009, 04:36 PM
good work :yes
i saw all your inbox :D
Ulrich
05-02-2009, 10:32 AM
Hello,
I have completed the SMTP client example project. This demonstration project shows you how you can send email directly from AutoPlay Media Studio, using this plugin.
http://www.mindquake.com.br/files/ams/SNAG-090502-01.jpg
For the sake of simplicity, I had to cut some corners in the demo. Normally, you should use the mail servers that your ISP has assigned to you, instead of delivering email directly to a remote SMTP server. So, while the example project may work correctly, you may encounter some difficulties because the messages might be classified as junk. I try to find out the mail server where the test message has to be delivered to, and this attempt may fail, of course. Anyway, this is just an example, not pretending to be a complete mail sending solution.
For those who already downloaded the plugin installer, just fetch the updated help file, from here (http://www.mindquake.com.br/files/ams/Socket.zip), where a link to the new example project can be found.
Ulrich
ShadowUK
05-02-2009, 10:44 AM
Hey, read my PM please. :3
Also, Do you think you could make an IRC example?
ShadowUK
05-02-2009, 11:48 AM
Double post, sorry.
As long as I didn't miss anything and it's already there could we could get a Socket.SetPort for server sockets and Socket.SetMaxClients?
Ulrich
05-02-2009, 11:57 AM
As long as I didn't miss anything and it's already there could we could get a Socket.SetPort for server sockets and Socket.SetMaxClients?
Hello,
yes, this should be possible. As these are parameters that (I thought) normally would not change in runtime, currently they can be set only through the Socket properties dialog. I'll update the plugin to include these functions.
Ulrich
ShadowUK
05-02-2009, 12:17 PM
Hello,
yes, this should be possible. As these are parameters that (I thought) normally would not change in runtime, currently they can be set only through the Socket properties dialog. I'll update the plugin to include these functions.
Ulrich
Thanks. This is by far my favourite plugin after playing around with it. It's defiently what I'm looking for to continue an old project.
coffeeworm
05-03-2009, 05:21 AM
:huhWhen I testing POP3Client example.
It seens Show inaccuracy.
like the attachment I post.
Ulrich
05-03-2009, 07:50 AM
:huhWhen I testing POP3Client example.
It seens Show inaccuracy.
like the attachment I post.
Hello Cheng,
this is normal, and shouldn't be understood as an error in the example code. See, the email protocol was originally developed to work with ASCII only, and only ASCII characters were used in the first email messages. Only later support for other character sets was added, like big-5 Chinese as in your case, ISO-8859-1 to allow accents and diacritics for Spanish and Portuguese languages, KOI8-R for Cyrillic messages, and so on. However, the email still is stored in plain ASCII on the mail server, and a real email client would need to perform correct character encoding / decoding to display the text in all fields (sender, recipient, subject, message body) properly. However, this example just shows the source code of the message in your mailbox, without the decoding part - you could certainly add this, if you need.
Ulrich
ShadowUK
05-03-2009, 07:57 AM
Hey, upeters.
I've been playing around with this plugin non-stop and I love it!
I managed to connect to the IRC protocol after a lot of reading the RFC 1459.
Here's an example, It connects to a server and channel and you can input raw commands like "PRIVMSG ShadowUK Hello!".
Enjoy. (if it works.)
http://shadiku.com/IRC.zip (1mb limit :O)
http://imgkk.com/i/d7c8ncz.png
Ulrich
05-03-2009, 09:58 AM
Hello,
new actions Socket.SetMaxClients() and Socket.SetPort() added to the plugin as requested. I updated the installer, but if you prefer you can just replace the current files with their updated versions, contained in this zip file (http://www.mindquake.com.br/files/ams/Socket.zip).
Ulrich
ShadowUK
05-03-2009, 10:32 AM
Hello,
new actions Socket.SetMaxClients() and Socket.SetPort() added to the plugin as requested. I updated the installer, but if you prefer you can just replace the current files with their updated versions, contained in this zip file (http://www.mindquake.com.br/files/ams/Socket.zip).
Ulrich
Thanks, this is really useful.
Also, Possibility for a extra argument in Socket.Open?
Socket.Open(Plugin, Host, IP, Type[SOCKET_UDP/SOCKET_TCP])
I'm coding a system that connects to my clan's game server bot however, The instructions he's given me (http://www.gamingmasters.co.uk/showpost.php?p=27229&postcount=4) and the code I've come up (http://www.gamingmasters.co.uk/showpost.php?p=27232&postcount=5) didn't quite match. Could you give me a heads up to what the problem might be?
Vancete
05-03-2009, 11:47 AM
Is there any way to transfer files with this socket plugin?
Thanks for all!;)
rexzooly
05-03-2009, 01:30 PM
Is there any way to transfer files with this socket plugin?
Thanks for all!;)
i think if you change it to its code forgot what its called starts with a B lol you
should be able to but warring even on really good systems give files will lock up ams when sending if i am looking at all this right.:rolleyes
rexzooly
05-03-2009, 02:18 PM
i been looking at this and i think it will replace my messenger what i have made what used php but what i like to know is how would i set the globle address to a server and if server timed out a view another server so on so forth but also include friends and blocking problem is i am not sure how i would get the server to hold this and also don't know how to use a online server insted of a local server is this possable?
Ulrich
05-04-2009, 07:31 AM
Is there any way to transfer files with this socket plugin?
Thanks for all!;)
Hello,
the short answer is "yes".
The long answer is that you must implement your own protocol. The socket is just a mean to exchange data with a remote computer. This data can be anything, like a message of some chat, a command of a certain game, or - why not - a packet that carries part of a file. The problem thing is that you will have to encode the binary file into text first, before you are able to transfer it, because the socket plugin will only handle strings (which cannot contain null characters). So, this is essentially the same that is done when you send an attachment by email: the file is first encoded to plain text (ASCII) before it can be sent out. When your mail reaches the recipient, that text is again converted into binary, and transformed back into the original attachment. This technique is not part of the socket, and you have to write your code to make this happen.
Ulrich
Imagine Programming
05-04-2009, 12:05 PM
Encrypting it would be a way right? If it's an ASCII based encryption though.
Hello,
the short answer is "yes".
The long answer is that you must implement your own protocol. The socket is just a mean to exchange data with a remote computer. This data can be anything, like a message of some chat, a command of a certain game, or - why not - a packet that carries part of a file. The problem thing is that you will have to encode the binary file into text first, before you are able to transfer it, because the socket plugin will only handle strings (which cannot contain null characters). So, this is essentially the same that is done when you send an attachment by email: the file is first encoded to plain text (ASCII) before it can be sent out. When your mail reaches the recipient, that text is again converted into binary, and transformed back into the original attachment. This technique is not part of the socket, and you have to write your code to make this happen.
Ulrich
MicroByte
05-04-2009, 12:14 PM
Base64 is ANSCII based
so use "Crypto.Base64EncodeToString" and then send the string, but i would split large files into sections and add some kind of information structure to the end of the Base64 string to tell the reciver what to do with the file (combine 5 parts etc, filesize, CRC value) so the reciver can rebuild and check the recived file
Ulrich
05-14-2009, 04:52 PM
Hello,
I have updated the plugin a couple of times since I last posted here. It now has support for UDP sockets, three actions have changed slightly (Socket.FindServer(), Socket.GetHostByAddress() and Socket.GetHostByName()), and a new action was added: Socket.Ping().
With Socket.Ping(), you are now able to send true ICMP echo request packets to a remote computer. The action will return the number of milliseconds to get the answer from the remote host. Normally, all network adapters answer to echo requests, even if there is no service (like HTTP or FTP) running. A link to a small demo showing this new action was included in the documentation.
As always, the installer can be fetched from my site (http://www.mindquake.com.br/ams-socket.php#download), but if you prefer you can just replace the current files with their updated versions, contained in this zip (http://www.mindquake.com.br/files/ams/Socket.zip) file.
Ulrich
ShadowUK
05-15-2009, 12:32 AM
Hello,
I have updated the plugin a couple of times since I last posted here. It now has support for UDP sockets, three actions have changed slightly (Socket.FindServer(), Socket.GetHostByAddress() and Socket.GetHostByName()), and a new action was added: Socket.Ping().
With Socket.Ping(), you are now able to send true ICMP echo request packets to a remote computer. The action will return the number of milliseconds to get the answer from the remote host. Normally, all network adapters answer to echo requests, even if there is no service (like HTTP or FTP) running. A link to a small demo showing this new action was included in the documentation.
As always, the installer can be fetched from my site (http://www.mindquake.com.br/ams-socket.php#download), but if you prefer you can just replace the current files with their updated versions, contained in this zip (http://www.mindquake.com.br/files/ams/Socket.zip) file.
Ulrich
In the documentation Socket.FindServer seems to be referencing Socket.Connect which isn't a documentated function?
Also, The Socket.GetHostByAddress and Socket.GetHostByName examples are in the wrong order.
I really like this ICMP ping, It's better than running ping using File.Run.
Thanks!
Ulrich
05-15-2009, 07:35 AM
In the documentation Socket.FindServer seems to be referencing Socket.Connect which isn't a documentated function?
Also, The Socket.GetHostByAddress and Socket.GetHostByName examples are in the wrong order.
I really like this ICMP ping, It's better than running ping using File.Run.
Thanks!
Hello,
Socket.Connect() was how I called the Socket.Open() function during development. I missed fixing the example code in the help. Thank you, the help is now corrected, and you may use the same links as before if you want to download the updated files.
I'm glad to hear that you liked the Socket.Ping(). It gave me more trouble than I initially thought.
Ulrich
Centauri Soldier
05-15-2009, 12:27 PM
Been a long time since I've been on the forums and let me just say...OMFG! I have been plaguing the forums with requests for a plugin that does this. Great job Ulrich! :D
I was just about to buy reteset's toolbar plugin but I'm going with Ulrich's this time. Next paycheck for the toolbar...sorry reteset. Ur plugin is way cool too...
ShadowUK
05-15-2009, 01:20 PM
Been a long time since I've been on the forums and let me just say...OMFG! I have been plaguing the forums with requests for a plugin that does this. Great job Ulrich! :D
I was just about to buy reteset's toolbar plugin but I'm going with Ulrich's this time. Next paycheck for the toolbar...sorry reteset. Ur plugin is way cool too...
I would pay for toolbar but it doesn't look like it would be of any use to me who likes doing it manually. I just got my activation code and I can tell you, This was the most useful thing to come to AMS in a long time.
ShadowUK
06-06-2009, 05:16 AM
While making an IRC bot, I ran into a problem. The connection needs to be kept alive, but the plugin as far as I can see can't do that. I'm not too sure, It's quite urgent though. Is there a way to have keep-alive?
Ulrich
06-06-2009, 07:47 AM
The socket object will not disconnect by itself, and will keep the connection open as long as possible. There is no keep-alive function that could be implemented in the socket itself.
What does exist, in FTP connections for example, is that the FTP client sends commands by itself to keep the connection alive (http://help.globalscape.com/help/secureserver2/Allow_NOOP_Command.htm), like LIST, NOOP, etc. Otherwise, the FTP server could assume that the connection ended and that it did not receive the command for a graceful shutdown from the client, allowing it could close the open connection on the server's end.
I assume that a similar mechanism would have to be implemented in your IRC client: When nothing is done by the user for x seconds, the client itself would need to send a NOOP message just to signal that the connection is still alive and should not be severed from the server side.
Ulrich
ShadowUK
06-06-2009, 10:36 AM
The socket object will not disconnect by itself, and will keep the connection open as long as possible. There is no keep-alive function that could be implemented in the socket itself.
What does exist, in FTP connections for example, is that the FTP client sends commands by itself to keep the connection alive (http://help.globalscape.com/help/secureserver2/Allow_NOOP_Command.htm), like LIST, NOOP, etc. Otherwise, the FTP server could assume that the connection ended and that it did not receive the command for a graceful shutdown from the client, allowing it could close the open connection on the server's end.
I assume that a similar mechanism would have to be implemented in your IRC client: When nothing is done by the user for x seconds, the client itself would need to send a NOOP message just to signal that the connection is still alive and should not be severed from the server side.
Ulrich
I tried sending "VERSION" to the server every 5 seconds but kept Ping Timing out. I'm guessing it's because I'm not responding to the servers pings. >_<
ShadowUK
07-05-2009, 10:28 AM
A problem I encountered at school which caused a lot of Syntax Errors.
http://imgkk.com/i/Okssghmy.png
Ehm, after one day of using it, it's showing a message, Evaluation Expired.
Can anyone help me? :\
Mikhail
10-18-2009, 05:06 PM
Ehm, after one day of using it, it's showing a message, Evaluation Expired.
Can anyone help me? :\
Hi! Some options:
Buy the plugin:
http://www.mindquake.com.br/ams-socket.php
Reinstall it into a virtualized space, like SandBoxie or VirtualBox:
http://www.sandboxie.com/
http://www.virtualbox.org/
Try the "native" Lua sockets:
http://www.tecgraf.puc-rio.br/~diego/professional/luasocket/
Ulrich
10-18-2009, 08:36 PM
I am not sure what the issue was, I have sent him a code to extend the trial period when he posted that message, so he could test the plugin properly. However, I never heard back from him...
paul186
10-30-2009, 03:50 AM
is there anyway to connect the socket to a redirected ip address like "something.no-ip.com"? is it possible?
thanks for all and Good Work Ulrich i love this plugin. tested by me and works 100% on vista and windows seven!
Sakuya
10-30-2009, 04:03 AM
is there anyway to connect the socket to a redirected ip address like "something.no-ip.com"? is it possible?
thanks for all and Good Work Ulrich i love this plugin. tested by me and works 100% on vista and windows seven!
Not too sure on the exact function name but I think it's Socket.GetAddressByHost.
Ulrich
10-30-2009, 05:59 AM
Use Socket.GetHostByName() to get the current IP address associated with a server name.
-- find the dynamic ip address
address = Socket.GetHostByName("something.no-ip.com");
test = Application.GetLastError();
if (test == 0) then
conn = Socket.Open("mySocket", address, port);
else
Dialog.Message("Error", "Could not resolve this name, error " .. test, MB_OK);
end
Ulrich
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.