Your first Remote client and server : Remote Basics « Network Remote « VB.Net

VB.Net
1. 2D
2. Application
3. Class
4. Data Structure
5. Database ADO.net
6. Development
7. Event
8. File Directory
9. Generics
10. GUI
11. Language Basics
12. Network Remote
13. Thread
14. Windows System
15. XML
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
VB.Net » Network Remote » Remote BasicsScreenshots 
Your first Remote client and server

///////////////////////////////RemoteObject: general.vb
// Complie: vbc /target:library  general.vb



Public Interface IEmployeeManager
    Function getEmployee(ByVal id As IntegerAs Employee
End Interface

<Serializable()> _
Public Class Employee

    Public FirstName As String
    Public LastName As String
    Public DateOfBirth As DateTime


    Public Sub New()
        Console.WriteLine("Employee.constructor: Object created")
    End Sub 'New

    Public Function getAge() As Integer
        Console.WriteLine("In getAge Method")
        Return 30
    End Function
End Class



/////////////////////////////test.vb
// Complie: vbc /t:exe /r:general.dll test.vb

Imports System
Imports System.Runtime.Remoting
Imports System.Runtime.Remoting.Channels.Http
Imports System.Runtime.Remoting.Channels
Imports System.Runtime.Remoting.Proxies
Imports System.Runtime.Remoting.Messaging



Module Client

    Sub Main()
        Dim channel As New HttpChannel()
        ChannelServices.RegisterChannel(channel,false)
        Dim mgr As IEmployeeManager = CType(Activator.GetObject_
            GetType(IEmployeeManager)"http://localhost:1234/EmployeeManager.soap"), _
            IEmployeeManager)

        Console.WriteLine("Client.Main(): Reference to EmployeeManager acquired")

        Dim cust As Employee = mgr.getEmployee(4711)

        Dim age As Integer = cust.getAge()
        Console.WriteLine("Client.Main(): Employee {0} {1} is {2} years old.", _
            cust.FirstName, cust.LastName, age)

        Console.ReadLine()

    End Sub
End Module


///////////////////////////server.vb
// Complie: vbc /target:exe  /r:general.dll server.vb

Imports System
Imports System.Runtime.Remoting
Imports System.Runtime.Remoting.Channels.Http
Imports System.Runtime.Remoting.Channels

Class EmployeeManager
    Inherits MarshalByRefObject
    Implements IEmployeeManager

    Public Sub New()
        Console.WriteLine("EmployeeManager.constructor: Object created")
    End Sub

    Public Function getEmployee(ByVal id As IntegerAs Employee _
    Implements IEmployeeManager.getEmployee
        Console.WriteLine("EmployeeManager.getEmployee): Called")

        Dim tmp As New Employee()
        tmp.FirstName = "James"
        tmp.LastName = "Band"
        tmp.DateOfBirth = New DateTime(100774)

        Console.WriteLine(("EmployeeManager.getEmployee(): Returning " & _
            "Employee-Object"))

        Return tmp
    End Function
End Class

Module ServerStartup

    Sub Main()
        Console.WriteLine("ServerStartup.Main(): Server started")

        Dim chnl As New HttpChannel(1234)
        ChannelServices.RegisterChannel(chnl,false)

        RemotingConfiguration.RegisterWellKnownServiceType_
            GetType(EmployeeManager), _
            "EmployeeManager.soap", _
            WellKnownObjectMode.Singleton)

        
        Console.ReadLine()

    End Sub
End Module



           
       
Related examples in the same category
1. Validate Data remotely
2. Call remote object method to Get and set variable
w___w___w__.__j_av__a___2__s._c_om___ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.