SocketTools is a large collection of components that can be used to create a variety of applications, so deciding what protocols and controls you'll need to use will be the first step. SocketTools covers several general categories, and there is some cross-over between the components in terms of functionality. We'll cover the most common programming needs and discuss what protocols should be used. Note that this section doesn't cover all of the classes in SocketTools .NET, and more specific information for each component is available within the technical reference documentation.
One thing you'll discover as you start to use SocketTools is that the interface was intentionally designed to be consistent between many of the classes. For example, both the File Transfer Protocol and Hypertext Transfer Protocol classes can be used to upload and download files, and the properties, methods and events for both of those classes are very similar. Once you've become comfortable working with one of the classes, you'll find it very easy to use the other, related classes.
One of the most common requirements for an application is the ability to upload and download files, either over the Internet or between systems on a local intranet. There are two core protocols which are used for file transfers, the File Transfer Protocol (FTP) and the Hypertext Transfer Protocol (HTTP). The decision as to which protocol to use largely depends on whether or not the program must also perform any type of file management on the server. Because many of the methods in the FTP and HTTP classes are similar, you may wish to use both and simply give your users an option as to which protocol they prefer to use.
If your program needs to upload files or manage the files on the server, we recommend that you use FTP. In addition to uploading and downloading files, FTP can be used to rename or delete files, create directories, list the files in a directory and perform a variety of other functions. On the other hand, if you primarily need to just download files, HTTP can be a better choice. The protocol is simpler and you're less likely to encounter some of the issues that can arise when using FTP from behind a firewall.
It is also an option to use FTP to upload and manage files and HTTP to download files within the same program. The important thing to keep in mind is that if you want to use HTTP and need to upload files, you must make sure that the server has been configured for it. Most web servers do not support the ability to upload files by default; it requires the administrator to specifically enable that functionality.
The HttpClient class is also the appropriate choice when your application needs to integrate with web services or REST APIs. It can be used to submit XML or JSON formatted requests, set custom request headers, provide authentication information and process the response returned by the server.
This makes it useful for working with services that expose application data over HTTP, such as account management systems, payment processors, cloud services, monitoring platforms and other third-party APIs. The class supports common methods such as GET, POST, PUT, PATCH and DELETE, as well as custom commands for protocols and extensions built on HTTP, including WebDAV.
For applications that need to exchange structured data with a server, the HttpClient class provides the lower-level HTTP functionality while your application remains responsible for creating the request content and parsing the response. If you are specifically working with large language model APIs, you may wish to use the LlmClient class instead, which handles many of the provider-specific details for you.
If your application needs to integrate with large language models, the LlmClient class provides a common interface for sending prompts and receiving responses from both local model servers and cloud-based AI providers. It can be used to build features such as natural language assistants, text summarization, code generation, content analysis and other AI-powered functionality.
The class is designed to simplify the process of working with different providers by using the same general programming model regardless of where the model is hosted. For example, an application can connect to a local server such as LM Studio or Ollama during development, and later use a cloud-based provider by changing the provider, endpoint, model name and authentication settings.
Unlike the lower-level HttpClient class, which requires your application to create the JSON request and process the response directly, the LlmClient class manages the provider-specific details for you. It also provides support for conversation history, token usage, model information and common configuration options such as the selected model and API key.
There are a number of SocketTools components which can be used by an application that needs to send email messages or retrieve them from a user's mailbox. The email related controls can be broken into three groups, those that deal primarily with managing and retrieving messages for a user, those which are used to send messages and those which can be used for either purpose.
The two principal protocols used to manage a user's email are the Post Office Protocol (POP3) and the Internet Message Access Protocol (IMAP). POP3 is the protocol that the majority of Internet Service Providers (ISP) use to give their customers access to their messages. It is primarily designed to enable an application to download the messages from the mail server and store them on the local system. Once all of the messages have been downloaded, they are deleted from the server. The user's mailbox is essentially treated as a temporary storage area.
On the other hand, IMAP is designed to allow the application to manage the messages on the server. You can create new mailboxes, move messages between mailboxes and search for messages. Because IMAP can be used to access specific parts of a message, it's not necessary to download the entire message if you just want to read a specific part of it. In terms of the SocketTools classes, it's useful to think of the properties, methods and events in the ImapClient class as a superset of those in the PopClient class. You'll find that methods used for accessing messages are very similar, but the IMAP component contains additional methods for managing mailboxes and performing operations that are specific to that protocol, such as the ability to search for messages.
To send an email message to someone, the protocol that you'll use is the Simple Mail Transfer Protocol (SMTP). The SmtpClient class supports the standard implementation of this protocol, along with many of the extensions that have been added since its original design. Extended SMTP (ESMTP) provides features such as authentication, delivery status notification, secure connections using TLS and so on. Another component that you may use is the DnsClient (DNS) class, which your application can use to determine what servers are responsible for accepting mail for a particular user.
Common to both sending and receiving email messages is the need to be able to create and process those messages. An email message has a specific structure which is defined by a number of standards, collectively called the Multipurpose Internet Mail Extensions (MIME). The MailMessage class can be used to create messages in the format, as well as parse existing messages so that you application can access the specific information that it needs. For example, you can use this class to attach files to a message as well as extract a specific file attachment from a message and store it on the local system.
If you need to establish an interactive terminal session with a server, there are two protocols that you can use. The most common is the Secure Shell (SSH) protocol. However, there is also the TELNET protocol is commonly used with legacy platforms and local devices. Either of these protocols are typically used in conjunction with the Terminal Emulation control, which provides ANSI and DEC VT-220 terminal emulation functionality. Used together, the user can login and interact with the server in the same way that they would use a console or character based terminal.
If you need to access newsgroups, the Network News Transfer Protocol (NNTP) will enable you to connect, list, retrieve and post articles. Because news articles have a format that is very similar to email messages, the MailMessage class can be used to parse articles that you've downloaded or create new articles to be posted. If you need to attach a file to the article that you're posting, the FileEncoder class can be used to encode the file using the yEnc encoding algorithm, which has become the de facto standard on USENET.