Server and Client in Distributed AjSharp

In my previous posts:

I wrote a brief description of what I want for distributed AjSharp (my open source interpreter), and few screenshots of running programs. Let examine and run a first concrete example.

As usual, you can launch the interactive interpreter with


You can add a list of .ajs program files to read and run inmediatly:

AjSharp.Console program1.ajs program2.ajs

The idea in this first distributed example is to launch two instances of the interpreter, and then, start a server in the first one, and start a client of that server in the second one. After connection is done, the client can execute commands in the server.

First, the server code:

server = new RemotingHostServer(10000, "Server");
PrintLine("Server started");

The built-in class RemotingHostServer starts a remoting server connection. The first parameter is the TCP port, and the second parameter the logic name of the server.

Now, the code for the client node:

remote = new RemotingHostClient("localhost", 10000, "Server");
at remote PrintLine("New Node");
nodeid = System.Guid.NewGuid().ToString();
// evaluate a subroutine at server
at remote 
		for (k=1; k<=10; k++)
			PrintLine("Hello, server, from node " + id);
	with (nodeid); // local parameter going to server

The object RemotingHostClient connects with a server. Its constructor takes three parameters: the machine name, the TCP port to use, and the logical name of the server. Using these parameters, it builds a remoting address, using a TCP channel.

Now, you have a connection with the server. The at command execute a command in a remote server. The syntax is:

at <server> <cmd>


at remote PrintLine(“New Node”);

prints a message in the server console, not in the client. The other variant:

at <server> <functionorsub> with (<parameters>);

evaluates a function or subroutine at the server, passing the parameter list, evaluated in the client environment.

I prepared a packaged example, you can download from my Skydrive:

In a console, execute


This command starts a new console, executing Server.ajs code.

To run a node


This is the typical output at the server side:

As usual, you can get the complete source from:

under trunk/AjLanguage. More distributed examples are comming: execute a local source code file at the server, do something at server when a new node is running, distributed agents, etc…

Keep tuned!

Angel “Java” Lopez

1 thought on “Server and Client in Distributed AjSharp

  1. agree with this

    Some directories have default descriptions for particular categories. Using this method will keep you safe from being punished by Google’s strict rules on SEO, and will also mean that what traffic you do get from your SEO work is actually useful and could lead to real sales. A good SEO agency will have someone who is fluent in English, even if they are located in another country.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s