Hi all, Is there a command to send and receive TCP messages
Forum rules
This is a sub-forum for things specific to MicroMacro.
This is not the place to ask questions about the RoM bot, which uses MicroMacro. There is a difference.
This is a sub-forum for things specific to MicroMacro.
This is not the place to ask questions about the RoM bot, which uses MicroMacro. There is a difference.
- Administrator
- Site Admin
- Posts: 5329
- Joined: Sat Jan 05, 2008 4:21 pm
Re: Hi all, Is there a command to send and receive TCP messa
Yes. I like the idea of how my networking works, but I have to admit it is a bit too restrictive at times. I've considered ditching it and just adding encryption functions to MicroMacro so users could use LuaSocket instead.
Re: Hi all, Is there a command to send and receive TCP messa
Was kind of thinking it would be cool if the main parts of MM were written as modules .. keyboard/mouse, memory, etc. then could just use it on standard Lua distribution and mix-and-match the parts you need... guess you can still do that to an extent with MM.
-
- Posts: 446
- Joined: Wed Aug 03, 2011 7:37 pm
Re: Hi all, Is there a command to send and receive TCP messa
I could never find any doco on the mm networking stuff - my useless forum searching skills rearing their ugly head 
So I endd up using LuaSocket too and just created a class for the client side (my server side is all .net C# code).

So I endd up using LuaSocket too and just created a class for the client side (my server side is all .net C# code).
Code: Select all
require "socket"
CServerLink = class(
function (self, server, port, readTimeout)
self.Server = server or settings.profile.options.SERVER_NAME;
self.Port = port or tonumber(settings.profile.options.SERVER_PORT);
self.ReadTimeout = readTimeout or 5;
self.Socket = socket.tcp();
self.Socket:settimeout(readTimeout);
self.Socket:connect(self.Server, self.Port);
end
)
function CServerLink:send(data, waitForResult)
self.Socket:send(data);
--printf("serverlink:send->"..data.."\n");
if ((waitForResult) and (waitForResult == true)) then
local data = "";
local sIn = self.Socket:receive(1);
while (sIn ~= "\0") do
if (sIn) then data = data..sIn; end;
sIn = self.Socket:receive(1);
end;
--printf(data.."\n");
return data;
end;
-- self.Socket:close();
end;
function CServerLink:close()
self.Socket:close();
end;
Who is online
Users browsing this forum: No registered users and 1 guest