| Network programming
can be tough and complicated. If you are reading this because
you are trying to decide on a communication mechanism for your
new project then let me save you some reading. Stick with something
else if you can.
Web Services gives you operating system and
limited language independence and can be done over a range of
transport. I have shown in another article how to use a Win
Form as a web service client. .NET and Java have great web services
support or you can fashion something in C++ using Xerces or
other mechanisms easily enough. .NET remoting is a good choice
if it is all .NET. If you need socket based communications then
make sure there is not an easier option than writing your own.
If you need to support multiple legacy clients then you may
have to go this route but check and see if there are any applicable
third-party libraries you can use.
But if you need to write your own then this
article will teach you how to do it in .NET using C#. We will
look at more advanced techniques in .NET socket communications.
If you only need a basic listener and client you should look
into the Socket helper classes. These include the TcpClient,
TcpServer and UdpClient classes in the Sockets namespace. Since
UDP is connectionless there is no listener and the same class
is used for your client and server. These classes are still
powerful and will fulfill most production needs with few lines
of code and fewer options and parameters to know.
Many programs of this type are written in C
or C++. While the technology in .NET socket applications is
not actually simpler than C++, it is simpler for you to write
and maintain them in C# because .NET provides better abstraction
of the underlying Win32 API functions.
NEXT>>
|