August 2011

You are browsing the site archives by month.

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 →

Telkomsel 3445 Text Message

What the hell… Thursday evening, August 14, 2011 i got a message from 3445 telkomsel. It said that my phone bill already reached Rp. 770,079. First i think that message was system fault but after i checked again with *888# it said my bill already reached Rp. 900k OMG! The next thing that appear in my mind was the internet package so i checked it, “UL INFO” send to 3636 but it said that i didn’t registered any internet packages. That’s the problem, i still have a message that said i’m registered the unlimited internet packages until August 10th.

Next day, of course i’m going to telkomsel’s customer services, fortunately the CS said there is a system error so my bill will be recalculated and i can go home. Hwoa… that was a shocking messages i can’t imagine paying 900k just for a month for phone bill.