Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>cbrotherNew to Visual Studio Code? Get it now.
cbrother

cbrother

CBrother Script

|
4,542 installs
| (0) | Free
cbrother
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

cbrother for Visual Studio Code

A Visual Studio Code extension for the CBrother Script.

What's CBrother

CBrother is a cross platform script, which abandons the GIL(global interpreter lock) used in traditional scripts, and supports real threads.
website: http://www.cbrother.net

Quick start

  • Step 1. download cbrother.
  • Step 2. Configure CBrother Path. (Settings -> Extensions -> CBrother -> CBrotherPath)
  • Step 3. Create code file and run! (Right down -> Run CBrother)

Debug

  • Step 1. Configure lanuch.js.
  • Step 2. Press F5

Example

helloworld

function main()
{
    print "Hello World!";
}

Base Type

var v1 = 100;       //int
var v2 = 100.0;     //float
var v3 = "100";     //string
var v4 = true;      //bool
var v5 = null;      //null
var v6;	            //null
var v7 = UINT(100); //unsigned int

var v8 = 0x00ff00aa;	    //int
var v9 = 0o11537;	        //int
var v10 = 0b10101;	        //int

var v11 = new Array();	    //array
var v12 = new Map();	    //map
var v13 = new List();	    //list

class MyClass
{
    var a = 100;
    var b = "100";
}
var v14 = new MyClass();	//custom class

var v15 = 0xffffffffffff0000;	    //long(64 bit)
var v16 = 4200000000;		        //long(64 bit)
var v17 = 'a';			            //int(ascii is 97)

Start an HTTP server


class HelloAction
{
	function DoAction(request,respon)
	{
		var myTime = new Time();
		respon.write("now time is:" + myTime.strftime("%Y/%m/%d %H:%M:%S"));
		respon.flush();
	}	
}

function main(parm)
{
	var httpServer = new HttpServer();
	httpServer.addAction("hello.cb",new HelloAction());//http://127.0.0.1/hello.cb
	httpServer.startServer(80);
	
	while(1)
	{
		Sleep(1000);
	}
}

Start an TCP server


class TcpAction
{
	var tcpModule;
	function OnAccept(sock)
	{

	}
	
	function OnClose(sock)
	{
		
	}
	
	function OnRecv(sock,byteArray,len)
	{		
		var byteArray = new ByteArray();
		byteArray.writeString("hello tcp client");
		tcpModule.sendData(sock,byteArray);
	}
	
	function OnSend(sock,len)
	{
		print "onsend " + sock + " " + len;
	}
}

function main(parm)
{
	var tcpModule = new TcpModule();
	var tcpAction = new TcpAction();
	tcpAction.tcpModule = tcpModule;
	tcpModule.setTcpAction(tcpAction);
	tcpModule.addListenPort(6060);	//listen 6060
	tcpModule.addListenPort(6061,"*");	//IPv4 and IPv6 compatible
	tcpModule.start();
	
	while(1)
	{
		Sleep(1000);
	}
}
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft