Posts

Showing posts from 2008

HTTP Connection Limit in .Net

There exists a web specification which suggests a server endpoint only allow up to two connections from any client at a time. The .Net Framework builds this limit in by default. This means that if you are trying to use HTTPWebRequest, WebRequest, etc, and attempt to maintain more than two connections at a time, it simply will not work. There is a rare case where a client application would require more than two maintained connections, though we found one in trying to watch more than two camera feeds from a video server. You can get around this limitation by changing the default connection limit like so: System.Net.ServicePointManger.DefaultConnectionLimit = 4;

Creating .Net COM objects for interop with VB6

.Net has some nice tools to help you create COM objects. .Net COM objects are slightly different from regular that regular COM objects in that the .Net is still in its intermediate language form. Because of this, you cannot register a .Net COM object with "regsvr32" as usual, you must use "regasm", which comes with the .Net framework. There are a few project properties that in Visual Studio that will do a lot of the work for you. First, create a standard class library project, or open an existing one. Go to the project properties and change the following settings. On the "Application" tab, click the "Assembly Information" button. Check the box to "make assembly com-visible". This option will wrap your library as a COM library. Next go to the "Build" tab and check the box to "Register for COM interop". This option will automatically register the output dll with regasm on the current machine after a build. The final, o

A Quick Note On Ports and Sockets

At this point, most people are familiar with the use of an IP address. Basically it is a unique number used on a network to identify a network computer. When we talk about computers communicating with each other, an IP address alone is useless. A single computer may have many programs running that want to communicate over the network. This means that a single address point (the IP address) is not enough to define what program a remote computer would like to communicate with. This is where port numbers come in. A program can bind itself to one or many open ports (meaning they are not currently in use by another program). Once bound to a port, a remote computer can communicate with a program by addressing the computer's address (IP) along with the program's address on that computer (Port). A common misconception is that a socket represents a bound port on a computer (the IP:Port pair). In reality, this is only half of what a socket represents. In fact, a socket represe

Visual Studio Project Settings

When I first started using the settings feature that was built into Visual Studio, I thought that they were pretty straight forward. It turns out that I had virtually no idea what was really going on. This is probably has mostly to do with MSDN's lack of documentation, as usual. Now I will attempt to lay out how this monster really works. First goto the properties page of a project and goto the settings tab. From here you can set up either Application or User settings. It turns out that the differences are pretty self explanitory. A user setting will actually end up in a user.config file burried in the Documents And Settings folder for each user. This means that each user will be able to have a different set of settings for these. Application settings are actually read from the myapp.exe.config file in the application path (usually in Program Files). To access these settings from code, all you need to do is: string mySetting = Properties.Settings.Default.MySetting; If you are acces

TableAdapter.Update Error

Error Exception: InvalidOperationException Error Message: Update requires a valid UpdateCommand when passed DataRow collection with modified rows. Problem: The update command is missing from the table adapter. Cause: I believe that this must have occured by changing the database structure after the dataset was created from it. Solution: Configure the data table of for the table in question. Assure that "Generate Insert, Update and Delete Statments" is checked inside of Advanced Options. Finish the wizard. Your command statements will be rebuilt (including the Update command).

The wonderful world of UDP Broadcasts

I have been working on a set of server/client applications lately. Basically, the server and client communicate via TCP. This means you need to provide an IP address and port number that the server is on so that the client can connect to it. The problem is that many users do not understand what an IP address is, much less how to find one; all hope is lost, then, if they must supply a port as well. The port problem is somewhat resolved in that the port number is typically fixed. No mater what machine the server is on, it will always communicate on say, port 4040. This will only be a problem if another application on the same machine is also attempting to use port 4040. The more complex issue to try to get around is obtaining the IP address. Every machine will have a different IP address, and even then it may change every time you enable its network device. Now assuming that your server and client will be on two machines that are very close to one another (not spanning across t