Network "library"

agraham

Expert
Licensed User
Longtime User
This is not a library as in "compiled dll" but it is as in "reusable code" so this is probably the best place for it.

I have been wanting to do two things. First to communicate between separate apps on the desktop and secondly to communicate between my device and desktop apps. I can do both with this network "library" that builds on network.dll!

Handling errors and structuring network code to be robust can be difficult so in doing the work I have implemented it as a reusable library and have provided defined interfaces to the code so that you don't need to know what is happening to use it. There is a comment region that tries to explain how.

I have included the "library" code in a demo app. This app can talk to another instance of itself, one being the server and the other the client. For the client to connect the server must be open first. You can use either a host name or an IP address. The default is "localhost" - your computer. Run two instances on your desktop - open one as the server and then the other as a client and type away! Your firewall may complain so you may have to let it know the programs are OK.

I have tested this over my WiFi network between all combinations of my Vista desktop, XP laptop and WM2003SE device, each being both server and client, with no problems.

I'm quite pleased with this and hope it might be useful to someone else.


EDIT :- I have just noticed an error in the comments for the network code. The line -

' netServerConnecting - the application must implement this know the server has a client

wasn't changed when I altered the final code and should be -

' netConnecting - the application must implement this to know that server and client are connected. It occurs for both server and client.
 

Attachments

  • NetDemo.zip
    116 KB · Views: 346
Last edited:

Cableguy

Expert
Licensed User
Longtime User
Very ussefull piece of code....

Thanks for all your hard work!
 
Top