Hi all, Is there a command to send and receive TCP messages

Discuss, ask for help, share ideas, give suggestions, read tutorials, and tell us about bugs you have found with MicroMacro in here.

Do not post RoM-Bot stuff here. There is a subforum for that.
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.
Message
Author
User avatar
Administrator
Site Admin
Posts: 5307
Joined: Sat Jan 05, 2008 4:21 pm

Re: Hi all, Is there a command to send and receive TCP messa

#21 Post by Administrator » Fri Mar 30, 2012 5:37 pm

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.

vIndie
Posts: 9
Joined: Thu Mar 29, 2012 12:35 am

Re: Hi all, Is there a command to send and receive TCP messa

#22 Post by vIndie » Sun Apr 01, 2012 12:47 pm

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.

BillDoorNZ
Posts: 446
Joined: Wed Aug 03, 2011 7:37 pm

Re: Hi all, Is there a command to send and receive TCP messa

#23 Post by BillDoorNZ » Sun Apr 01, 2012 2:43 pm

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).

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;

Post Reply

Who is online

Users browsing this forum: No registered users and 12 guests