Click here to Skip to main content
Click here to Skip to main content

TCP/IP with VB.NET

, 12 Aug 2004
Rate this:
Please Sign up or sign in to vote.
TCP/IP with VB.NET.

Introduction

This article includes a demonstration of a very very easy to use library for giving TCP/IP functionalities to your .NET application. The library and source code are provided, and also a basic example application that shows how to implement the classes exposed by the library.

Any comment of any kind is welcome at uno.one@email.it.

There are also other UNOLibs, ask for the ones you would like to have released in CodeProject at uno.one@email.it.

Click here to go to UnoLibs.Net V2 (Strongly recommended).

The Source Code

The source code includes:

  1. UNOLibs.Net assembly code
  2. Example application code

The two code are in the same Visual Studio 2003 Solution, in two separate projects. The project of the example application references the UNOLibs.Net project.

Am I willing to read this?

  • This article shows the usage of one of the most easiest libraries for TCP/IP communication, for use with .NET framework 1.1.
  • The UNOLibs.Net code is not commented and you don't need to read it or understand it if you don't want to.
  • The application example code is highly commented and will provide you the information needed for implementing your application using UNOLibs.Net assembly.
  • Generally, you should be interested if you program in any .NET environment such as VB.NET, C#, J#, or C++.NET, and want to give TCP/IP functionality to your application without having to bug with threading and sockets and generally annoying stuff.

How do I use this?

If you are willing to use UNOLibs.net assembly in your projects:

  1. You made a good choice!
  2. It's strongly recommended for you to have a look at the example application code.
  3. Download the assembly (or compile your own using the source code).
  4. Add the reference to the assembly in your .NET project.

Now it depends on what you want to implement, however:

UNOLibs.Net exposes 3 Classes:

  • UNOLibs.Net.ClientClass
  • UNOLibs.Net.ServerClass
  • UNOLibs.Net.ServerScanner

You can find detailed references about the classes in the reference.txt file placed in the assembly zip file.

However, I'll write topic usage for these classes here:

ClientClass usage

  • Create it.
    Dim Cli as New UNOLibs.Net.ClientClass
  • Use it to send a specified MESSAGE on specified IP and PORT.
    Cli.SendMessage(IP,PORT,MESSAGE)
  • Really, no more code is needed.

ServerClass usage

  • Create and initialize it on specified PORT; using True will autostart the server.
    Dim WithEvents Srv as new UNOLibs.Net.ServerClass(PORT,True)
  • Write what to do when a message is received, doing this with a Sub that handles the incoming message event.
    Private sub OnIncomingMessage(Args as _
      UNOLibs.Net.ServerClass.InMessEvArgs) handles Srv.IncomingMessage
        'Retrieve received message:
        Dim M as string = Args.Message
        'Retrieve sender IP
        Dim sIP as string = Args.senderIP
        'What you like here.. for example : 
        If M.equals("anystring") then
            anysub()
        End If
    End Sub
  • Really, no more code is needed.

ServerScanner usage

  • Create Scan parameters for creation and initialization of Scanner.
    Dim ScanParameters As New UNOLibs.Net.ServerScanner.ScannerParameters
        ScanParameters.SubnetToScanIP = Me.IPscanRange.Text
        ScanParameters.TCPPort = Me.ScanPort.Value
        ScanParameters.useProgressBarEvent = false
        Scanner = New UNOLibs.Net.ServerScanner(ScanParameters)
        'For using the ProgressBarEvent just have a better view in the code
        'of the example app, everyhing still remains very very easy
  • Start the server.
    Scanner.StartScan
  • What to do when IPs are found?
    Private sub OnIPFound(IP as String)Handles Scanner.IPfound
        'For example write the scanned IP into a textbox.
        Me.textbox1.text = IP
    End Sub
  • Really, no more code is needed.

Particular interests

Well, just that even if the architecture is very easy, events way means that the server application will start 1 new thread for processing eventual messages from many clients at an interval of every 100ms (you can change this in the code), and it's so easy to use (that is, made with 3 lines + the ones from your code).

  • No deal with Sockets.
  • No deal with Threads.
  • Multithreaded EventFlexible server.
  • Client communication with 1 line of code per message
  • Multithreaded customizable Scanner, ready to sync with your progressbar.

Limitations

Source code is in VB.NET but the assembly should work fine in any .NET environment supporting "System.Net" namespace, Multithreading, and Event Handling, such as (VB.NET, C#, J# , C++.NET).

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

uno freeware
Web Developer
Italy Italy
...picture was not for codeproject hihihi.
well my usual way is to release only classes wich can be used by you very easily and quickly.

Comments and Discussions

 
Questionhi Pinmembertaneka20-Feb-12 11:34 
Questionsalam Pinmemberarastoooo6-Sep-11 10:48 
QuestionHow To: Receive Data from the Client Class? Pinmemberantonio62228-Jan-11 9:00 
GeneralSpecial charcaters PinmemberPenelopeGuido15-Aug-06 1:06 
GeneralEvent when connect to Port PinmemberVitoto20-Jun-05 11:01 
GeneralRe: Event when connect to Port PinmemberUno freeware22-Jun-05 5:39 
GeneralRe: Event when connect to Port PinmemberUno freeware22-Jun-05 5:44 
GeneralRe: Event when connect to Port PinsussAnonymous22-Jun-05 6:16 
GeneralRe: Event when connect to Port PinmemberUno freeware22-Jun-05 7:15 
GeneralRe: Event when connect to Port PinmemberVitoto22-Jun-05 16:11 
GeneralRe: Event when connect to Port PinmemberUno freeware23-Jun-05 7:26 
GeneralRe: Event when connect to Port PinmemberVitoto23-Jun-05 8:14 
GeneralSystem.NullReferenceException Error PinmemberCurse4Life20-Jun-05 5:33 
GeneralRe: System.NullReferenceException Error PinmemberUno freeware22-Jun-05 5:27 
GeneralRe: System.NullReferenceException Error PinmemberCurse4Life22-Jun-05 21:38 
GeneralRe: System.NullReferenceException Error PinmemberUno freeware23-Jun-05 7:24 
GeneralRe: System.NullReferenceException Error PinmemberPenelopeGuido14-Aug-06 8:38 
GeneralRe: System.NullReferenceException Error PinmemberUno freeware22-Jun-05 5:45 
GeneralPEOPLE GOTO UNOLIBS V2 PinmemberUno freeware15-Jun-05 18:37 
Generalnnbn Pinsussraj451115-Apr-05 4:57 
GeneralRe: nnbn PinsussUno.Freeware16-Apr-05 10:34 
QuestionWhy this low rating? PinmemberBlueFront27-Mar-05 22:02 
AnswerRe: Why this low rating? PinsussUno.Freeware7-Apr-05 17:21 
GeneralWhy does this only work on the LAN?.... PinsussNoDimensions29-Jan-05 6:13 
GeneralRe: Why does this only work on the LAN?.... PinmemberUno freeware30-Jan-05 19:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.141223.1 | Last Updated 13 Aug 2004
Article Copyright 2004 by uno freeware
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid