example/VB.NET/Makefile.am no UNIX build possible, mono tool vbnc is still in development
win.example/VB.NET/MyServer.vb
Imports System
Imports csmsgque
Public Module example
Private Class MyServer
Inherits MqS
Implements IServerSetup
Implements IFactory
' service definition
Public Function Factory() As csmsgque.MqS Implements csmsgque.IFactory.Call
Return New MyServer()
End Function
' service to serve all incomming requests for token "HLWO"
Private Sub MyFirstService()
SendSTART()
SendC("Hello World")
SendRETURN()
End Sub
' define a service as link between the token "HLWO" and the callback "MyFirstService"
Public Sub ServerSetup() Implements csmsgque.IServerSetup.Call
ServiceCreate("HLWO", AddressOf MyFirstService)
End Sub
End Class
Sub Main(ByVal args() As String)
Dim srv As New MyServer()
Try
srv.ConfigSetName("MyServer")
srv.LinkCreate(args)
srv.ProcessEvent(MqS.WAIT.FOREVER)
Catch ex As Exception
srv.ErrorSet(ex)
Finally
srv.Exit()
End Try
End Sub
End Module
The server is started as network visible TCP server listen on PORT 2345 using a THREAD for every new connection request:
> mono MyServer.exe --tcp --port 2345 --thread
If you are using UNIX and if you want to setup a high-performance local server then use the build-in UDS (Unix-Domain-Sockets) capability to listen on the FILE /path/to/any/file.uds instead on a network port:
> MyServer --uds --file /path/to/any/file.uds --thread
Three things are important:
Services are created with the ctx.ServiceCreate(String token, AddressOf service) function. The first parameter is a 4 byte Token as public name. 4 byte is required because this string is mapped to a 4 byte integer for speed reason. The second parameter is an object providing the SERVICE CALLBACK interface.
The SERVICE CALLBACK function has one parameter of type MqS. This parameter refer to the original object (in our case MyServer). If the service object (in our case MyFirstService) is a subclass of the original MqS object class, the both statements SendSTART() and ctx.sendSTART() are identical.
Imports System
Imports csmsgque
Public Module example
Sub Main(ByVal args() As String)
Dim c As New MqS()
Try
c.LinkCreate(args)
c.SendSTART()
c.sendEND_AND_WAIT("HLWO", 5)
Console.WriteLine(c.ReadC())
Catch ex As Exception
c.ErrorSet(ex)
Finally
c.Exit()
End Try
End Sub
End Module
To call a network visible TCP server listen on PORT 2345 use:
> mono MyClient.exe --tcp --port 2345 > Hello World
To call a network visible UDP server listen on FILE /path/to/any/file.uds use:
> mono MyClient.exe --udp --file /path/to/any/file.uds > Hello World
To call a local server started by the client using PIPE communication use:
> mono MyClient.exe @ mono MyServer.exe > Hello World
1.5.8