r7 - 31 Aug 2007 - 21:11:44 - MatthiasGlastraYou are here: LanBoxWiki >  Main Web > LanboxCommandSet > CommandsInDotNetCs

Commands in .NET C#

C# has it origin in C. C is a programming language, one of many -- and indeed a fairly popular one. Much software is written in C and the related language C++. For example, most of the core parts of Mac OS X itself is written in C. Most of Linux is written in C. Max (from Cycling 74) is written in C.

More details are at:

Sending commands to the Lanbox in the .NET framework from Microsoft is not too difficult. Using a TcpClient object you connect to the corrrect ipadres and port and start sending commands. Below is an example written in C#. Just copy past and start working.

  • First it starts by setting op a TcpClient object that connects to a IpAdres and a port.
  • Second it creates a stream to read and write the data to the network.
  • Then you have to connect to the Lanbox. And send a password to connect.

C# Code example

public void Connect() 
{
    //Connect
    TcpClient client = new TcpClient("[adres]", [port]);
    NetworkStream nstream = client.GetStream();

    //On connection first login
    if (ReadStream(nstream).Contains("password")) 
    {
        WriteStream(nstream, "[password]\r");
        if (ReadStream(nstream).Contains("connected"))
            return true; //Connected
        else
            return false; //Connection failed
    }
}

public string ReadStream(NetworkStream stream) 
{
    byte[] bytes = new byte[256];
    stream.Read(bytes, 0, bytes.Lenght);

    return Encoding.ByteToString(bytes);
}

public void WriteStream(NetworkStream stream, string message) 
{
    byte[] bytes = Encoding.StringToByte(message);
    stream.Write(bytes, 0, bytes.Length);
}

This example is just a basic example to login. After this you could send command to the Lanbox see for commands the reference.

Lanbox SDK For a .NET based framework to communicate with the Lanbox see https://sourceforge.net/projects/xspotlanbox/. This is a project in development but has great functionality. And if you want to contribute you may. It's free for everybody. Just as open as the Lanbox.

-- MatthiasGlastra - 14 Aug 2007

Edit | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r7 < r6 < r5 < r4 < r3 | More topic actions

tip TWiki Tip of the Day
Keyword search
Interactive search is a keyword search by default. For example, to search for all topics that contain ... Read on Read more

 
LanBoxWiki
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding LanBoxWiki? Send feedback