Networking

Test Internet/Connection Speed from Linux Command Line

See complete post of Test Internet/Connection Speed from Linux Command Line

Do you use Ubuntu Server? or have a VPS or Dedicated Server hosting that runs Linux which only can be accessed via Console/Command Line/SSH? I Do! And now i want to check whether if the hosting company give me correct package of dedicated bandwidth for my server…

Yes, most people would think about speedtest.net, the most popular and distributed internet/connection speed test in the world. But the problem is speedtest.net is using a website and my server cannot open a web page and run the test widget there… Fortunately there is a “speedtest-cli” built on python and support any operating system as long as can run python code.

Read More →

If-Else vs If-If vs Switch Javascript Performance

View complete post of If-Else vs If-If vs Switch Javascript Performance

There are three major conditional syntax that used widely in almost all programming language: If, If-else, Switch. Now then which type of conditional is going to give fastest execution time so our software may perform better even it’s just micro optimization.

Of course many of us will said that there is no chance that “if if” or “multiple if” is going to be fastest type. So which is fastest? Switch or If Else…

Read More →

Simple HTTP Proxy Server C# Source Code

This time my next step for building the M-NIC Projects, creating a HTTP Proxy Server which is actually just an HTTP Relay :D. The concept just take everything from applications which HTTP Proxy server is set to my application then relaying the request to the destination server then relay again the response from destination server to client application.

The method? Just ordinary Socket Programming in C# (System.Net) Socket.Send(), Socket.Receive(), etc. First let’s take a look to the Server Listener, every server must listen to the incoming client connection. In this application, i’m using TcpListener for that.

using System.Net;
using System.Net.Sockets;

namespace SimpleHttpProxy
{
    class ServerListerner
    {
        private int listenPort;
        private TcpListener listener;

        public ServerListerner(int port)
        {
            this.listenPort = port;
            this.listener = new TcpListener(IPAddress.Any, this.listenPort);
        }

        public void StartServer()
        {
            this.listener.Start();
        }

        public void AcceptConnection()
        {
            Socket newClient = this.listener.AcceptSocket();
            ClientConnection client = new ClientConnection(newClient);
            client.StartHandling();
        }

    }
}

How it works? See the main method implementation below. Just initiate server listener object which is listen to port 9000 (this port number is up to you, but make sure you’re choosing free port number), then start the server to make the server ready to accept incoming connection and do the magic loop (actually just an infinite looping) to accept the incoming connection.

Read More →

Get All Local Network Interface Card (NIC) C# Source Code

Yeah, actually i’m back to blogger activities… This is the part of my next projects, M-NIC Projects. The goal is to get all information of our network interface card (NIC) information such as IP addresses, link speed, name, etc. So after doing some head-to-head within some programming languages, my choices is C# .NET, because i think it’s easiest way to get that. The result is something like below, i retrieve all of my NIC which status is UP

Name            : Wireless Network Connection 2
Type            : Wireless80211
Status          : Up
Speed           : 4294967295
Description     : Microsoft Virtual WiFi Miniport Adapter
InterNetworkV6  : fe80::e1cf:b2ee:f5c7:e23e%31
InterNetwork    : 192.168.2.1
=======================================
Name            : Local Area Connection
Type            : Ethernet
Status          : Up
Speed           : 100000000
Description     : Atheros AR8152 PCI-E Fast Ethernet Controller
InterNetwork    : 192.168.1.3
=======================================
Name            : Loopback Pseudo-Interface 1
Type            : Loopback
Status          : Up
Speed           : 1073741824
Description     : Software Loopback Interface 1
InterNetworkV6  : ::1
InterNetwork    : 127.0.0.1
=======================================

And here is the code: Read More →

Building PHP Webserver on Nginx with PHP CGI

Doesn’t like the Apache webserver, nginx didn’t have the auto-configuration feature from PHP and library loading. The way to make nginx be a PHP webserver is passing the request to PHP CGI. How?

The first step must be installing the nginx and php5 package. For this post i’m using Ubuntu 10.04 LTS.

apt-get update nginx
apt-get update php5

Check your nginx installation with start the service:

service nginx restart
/etc/init.d/nginx restart

Now, if the nginx working, let’s connect it to the PHP CGI. First, run the PHP CGI so that the PHP listen at 127.0.0.1 with port 9000.

/usr/bin/php-cgi -b 127.0.0.1:9000 &

Read More →