Tuesday, November 13, 2007

network problem?

Some DOS commands that can help determine network problems:
ping, tracert, nslookup, netstat

C:\Documents and Settings\unplug1.6>ping tttx-inst1.com

Pinging tttx-inst1.com [182.11.110.111] with 32 bytes of data:

Request timed out.
Request timed out.
Request timed out.
Request timed out.

Ping statistics for 182.11.110.111:
Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),


C:\Documents and Settings\unplug1.6>tracert minn

Tracing route to minn.xx.com [182.11.110.111]
over a maximum of 30 hops:

1 1 ms <1 ms <1 ms 182.11.110.111
2 * * * Request timed out.
3 25 ms 23 ms 24 ms 192.168.16.160
4 24 ms 23 ms 25 ms minn.xx.com [182.11.110.111]

If there were a problem with an ip, you can specify which ip to use in tracert:
tracert -j 180.16.116.116 oh-01.xx.com

Tracing route to oh-01.xx.com [180.16.116.116]
over a maximum of 30 hops:

1 * * * Request timed out.
2 * * * Request timed out.

Trace complete.

C:\Documents and Settings\unplug1.6>nslookup 192.168.16.160
Server: oh-01.xx.com
Address: 182.16.160.16

*** oh-01.xx.com can't find 192.168.16.160: Non-existent domain

Friday, November 9, 2007

C# threading example

This is a simple, but handy multi-thread example. The two "foreach" sections at the end is where the hip happens. All process' will start at the same time and "Main" will not exit until all threads have been joined.

static void Main(string[] args)
{
  ArrayList threads = new ArrayList();

  try
  {
    if(args.Length > 0)
  {

  switch(args[0].ToUpper())
  {
    case "case1" :
    {
      case1Export case1 = new case1Export();
      Thread t1 = new Thread(new ThreadStart(case1.Start));
      threads.Add(t1);
      break;
    }
    case "case2" :
    {
      case2Export case2 = new case2Export();
      Thread t2 = new Thread(new ThreadStart(case2.Start));
      threads.Add(t2);
      break;
    }
    case "case3" :
    {
      case3Export case3 = new case3Export();
      Thread t3 = new Thread(new ThreadStart(case3.Start));
      threads.Add(t3);
      break;
    }
    default :
      break;
    }
  }

  foreach(Thread thread in threads)
  {
    thread.Start();
  }

  foreach(Thread joinThread in threads)
  {
    joinThread.Join();
  }
}