Accessing the Internet From a Blackberry Simulator

Posted in Blackberry on September 24th, 2009 by Dave Andrews – 3 Comments

I had to work on a project recently which involved accessing a web page from a blackberry device. In order to know what it will look like exactly, I decided to write the page software on my machine, and use a Blackberry simulator from Research In Motion to pull up the page so I’ll know how it will look on the client phones.

Downloading the simulator was easy! You can get the Blackberry Simulator software here. But I ran into an issue: I couldn’t access the internet! All I would see when I opened the browser and tried to access a webpage was a “Requesting…” progress bar at the bottom. No internet access!

I would then receive the message “Unable to connect to the selected Mobile Data Service, please try again later.”

blackberry_nointernet

No Internet On The Simulator!

After a little bit of research I determined that what I needed is the “Blackberry Email and MDS Services Simulator.” You can download the MDS Services Simulator here. I downloaded and installed the simulator, but then I ran into another problem.

Error on the MDS Simulator

Error on the MDS Simulator

The internet on my blackberry simulator still was not working. I looked through the MDS output on the command prompt window, and I noticed an error: “java.net.BindException: Address Already In Use: JVM_Bind:8080″. Now, if you’ve read my sockets tutorial network primer, you know that a port can only be bound for listening once. So apparently I had another process on my PC which was bound to listen on port 8080.

So how can I tell which process was running on 8080? I stopped IIS, restarted MDS but I still got the error. I know from working in IT for so long, however, how I can tell what process is using what port.

Pull up a command prompt window and type the command:

C:\> netstat -a -b

You will get output like the image below. As you can see, there is a java process already using port 8080. All I did from there was kill that java process using the Task Manager, and restarted MDS.

java8080

Java.exe is LISTENING on port 8080.

Restarting MDS and the Blackberry Simulator after killing that java process made the blackberry simulator work. I was connecting to the internet just fine.

The simulator can hit the internet.

The simulator can hit the internet.

Chat Client/Server Part 1: Network Programming Primer and Packet Base Class

Posted in CSharp, Dot Net on September 14th, 2009 by Dave Andrews – 5 Comments

This is the first part of a multiple-post tutorial which will explain how to use the dot net TcpClient and TcpListener classes to create a multi-threaded network application. This result will manifest itself in a chat server and chat client.
read more »

Mobile Merge Replication combined with SSIS Packages

Posted in SQL, SSIS on September 11th, 2009 by Dave Andrews – 1 Comment

I have a project I’ve worked on recently which involved several database.

  1. Database 1 is the “master” database to which a web interface interacts.
  2. Database 2 is an “intermediate” database, which is set up for merge replication, to publish down to handheld clients running Windows Mobile.
  3. Database 3 is the database on the handhelds which subscribe to database 2.

Data can be entered in the web interface (and therefore directly to database 1) or it can be entered on the handheld, and replicated up to database 2. The handhelds can’t tie directle to database 1, because some transformations have to be applied.

To tie data back and forth between database 1 and 2, I have an SSIS package which runs every half hour to do the following:

  1. The package imports new data from the intermediate database.
  2. The package pushes any changes down from database 1 to database 2, to be replicated out to the handhelds.

Here is the problem I encountered. Any new record I put into the web interface would not make it down to the mobile handhelds, even after the SSIS package put the data into database 2 and the handheld synchronized. I would have to re-create the snapshot and then re-subscribe the handheld in order to see new records. That just won’t work!

After pulling my hair our for about an hour trying to figure out the problem, and a lot of web searching, I finally came across this amazing page about SQL replication which solved the problem immediately.

When populating a merge-replication published database using SSIS, DO NOT USE “FAST LOAD”. Fast load does not run the triggers on the tables which are being replicated, and those triggers have to run in order for replication to do its work. I just changed it from using “Fast Load” to using the normal method, and my replication worked like a charm!

Convert Byte Array to Hexidecimal String in C#

Posted in CSharp, Dot Net on September 10th, 2009 by Dave Andrews – 1 Comment

I had to write a function today which will take an arrayof bytes and convert those bytes into a hexidecimal string representation. This was part of an encryption algorithm. There are a couple on the net but they seem to be more complicated. Here is what I came up with (and this seems the simplest way to me, so there may be similar ones out there):

1
2
3
4
5
6
7
8
9
10
11
12
13
        public string ToHexString(byte[] array)
        {
            string vals = "0123456789ABCDEF";
            StringBuilder result = new StringBuilder();
 
            for (int i = 0; i < array.Length; i++)
            {
                result.Append(vals[array[i] >> 4]);
                result.Append(vals[array[i] & 15]);
            }
 
            return result.ToString();
        }