Platforms to show: All Mac Windows Linux Cross-Platform
/Win/Windows QOS/Windows QOS with TCPSocket
Required plugins for this example: MBS Win Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Win/Windows QOS/Windows QOS with TCPSocket
This example is the version from Mon, 5th Jan 2014.
Project "Windows QOS with TCPSocket.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control List Inherits Listbox
ControlInstance List Inherits Listbox
End Control
EventHandler Sub Close()
sock.Close
sock = nil
End EventHandler
EventHandler Sub Open()
sock = new MyTCPSocket
sock.Address = "macsw.de"
sock.port = 80
sock.Connect
End EventHandler
Property sock As MyTCPSocket
End Class
MenuBar MainMenuBar
MenuItem FileMenu = "&Ablage"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Bearbeiten"
MenuItem EditUndo = "&Rückgängig"
MenuItem EditSeparator1 = "-"
MenuItem EditCut = "&Ausschneiden"
MenuItem EditCopy = "&Kopieren"
MenuItem EditPaste = "&Einfügen"
MenuItem EditClear = "#App.kEditClear"
MenuItem EditSeparator2 = "-"
MenuItem EditSelectAll = "&Alles auswählen"
End MenuBar
Class MyTCPSocket Inherits TCPSocket
EventHandler Sub Connected()
log CurrentMethodName
#if TargetWin32 then
dim r as Boolean
FlowId = 0 // new flow
r = qos.AddSocketToFlow(me.Handle, qos.QOSTrafficTypeExcellentEffort, qos.QOSNonAdaptiveFlow, FlowId)
if not r then
log "Error: "+qos.LasterrorMessage
else
log "FlowID: "+str(FlowId)
end if
dim Bandwidth as UInt64 = 1024 * 1024 // 1 MBit
dim ShapingBehavior as integer = qos.QOSUseNonConformantMarkings
dim Reason as integer = qos.QOSFlowRateUserCaused
r = qos.setOutgoingRate(FlowID, Bandwidth, ShapingBehavior, Reason)
if not r then
log "Error: "+qos.LasterrorMessage
else
log "Outgoing Rate set."
end if
#endif
End EventHandler
EventHandler Sub Error()
log CurrentMethodName+": "+str(me.LastErrorCode)
End EventHandler
Sub Constructor()
// Calling the overridden superclass constructor.
// Note that this may need modifications if there are multiple constructor choices.
// Possible constructor calls:
// Constructor() -- From HTTPSocket
// Constructor() -- From TCPSocket
// Constructor() -- From SocketCore
Super.Constructor
log CurrentMethodName
qos = new WindowsQOSMBS
if qos.Lasterror<>0 then
log "Error: "+qos.LasterrorMessage
end if
End Sub
Sub Destructor()
log CurrentMethodName
#if TargetWin32 then
if qos<>Nil then
dim r as boolean = qos.RemoveAllSocketsFromFlow(flowid)
if not r then
log "Error: "+qos.LasterrorMessage
end if
qos = nil
end if
#endif
End Sub
Sub Log(s as string)
window1.List.AddRow s
End Sub
Property FlowId As UInt32
Property qos As WindowsQOSMBS
End Class
End Project
See also:
The items on this page are in the following plugins: MBS Win Plugin.