Inet & Winsock in .NET

pinster

Active member
Joined
Jan 28, 2002
Messages
29
Location
Penang, Malaysia
I know Inet Control and Winsock Control are both included in Socket Class. However, it would be great if someone who have the experience and knowledge in VB.NET to show us how to use Socket Class to achieve some if not all the functionality in Inet & Winsock through a comprehensive tutorial.

Eg. Inet.OpenURL is for downloading, Winsock.SendData is to send something and etc... but how it works in .NET socket class?

Besides, 1 thing I experience in Socket Class is that after I had downloaded a file, I must actually perform encoding to get the ASCII contents because everything downloaded is byte stream (I think...)... so, this is a highlight to inform others too..

Thanks for considering my suggestion. :)
 
The socket class is a very powerful component meant to replace the functionality of the Winsock control from VB6. I will be posting either a tutorial on it or some sample code in the near future.

As for the inet control, the socket class does not offer such a high-level approach to downloading data. This short snippet (courtesy of Derek I think) illustrates how easy it is to download data from HTTP synchronously in .NET:

Code:
Dim wcDownload As New System.Net.WebClient()
Dim bytDatabuffer As Byte() = wcDownload.DownloadData("http://www.microsoft.com/")
Dim strDatabuffer As String = System.Text.Encoding.ASCII.GetString(bytDatabuffer)

Having to manually encode/decode text took a bit of getting used to, but its good for platform independance, and it eliminates the need to use strings some of the time. Take sending a binary file by FTP for example - you use a BinaryReader to get a byte array from a file, and you can pass that byte array right to a Socket class to send it. No need for cumbersome strings where theyre not necessary.
 
Theres a good sample project on this included in Visual Studio.NET. Have you taken a look at
C:\Program Files\Microsoft Visual Studio .NET\FrameworkSDK\Samples\Applications\Wintalk\vb
this project?
 
Tutorials

Ive played w/ the the chat program that comes w/ .NET. I think, if divil were to demonstate the sockets class by creating a p2p chat program, hed do a more extensive job than microsoft did.
 
Back
Top