Platforms to show: All Mac Windows Linux Cross-Platform

/Network/PacketSocket Example


Required plugins for this example: MBS Network Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Network/PacketSocket Example

This example is the version from Sun, 17th Mar 2012.

Project "PacketSocket Example.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control TabPanel1 Inherits TabPanel
ControlInstance TabPanel1 Inherits TabPanel
End Control
Control EditField1 Inherits TextField
ControlInstance EditField1 Inherits TextField
End Control
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
Control listenButton Inherits PushButton
ControlInstance listenButton Inherits PushButton
EventHandler Sub Action() ConnectButton.Enabled=False listenButton.Enabled=False sock.port=val(EditField1.text) sock.Listen End EventHandler
End Control
Control StaticText2 Inherits Label
ControlInstance StaticText2 Inherits Label
End Control
Control StaticText3 Inherits Label
ControlInstance StaticText3 Inherits Label
End Control
Control EditField2 Inherits TextField
ControlInstance EditField2 Inherits TextField
End Control
Control StaticText4 Inherits Label
ControlInstance StaticText4 Inherits Label
End Control
Control ConnectButton Inherits PushButton
ControlInstance ConnectButton Inherits PushButton
EventHandler Sub Action() ConnectButton.Enabled=False listenButton.Enabled=False ConnectButton.Enabled=False listenButton.Enabled=False sock.port=val(EditField2.text) sock.Address=EditField3.text sock.Connect End EventHandler
End Control
Control StaticText5 Inherits Label
ControlInstance StaticText5 Inherits Label
End Control
Control StaticText6 Inherits Label
ControlInstance StaticText6 Inherits Label
End Control
Control EditField3 Inherits TextField
ControlInstance EditField3 Inherits TextField
End Control
Control StaticText7 Inherits Label
ControlInstance StaticText7 Inherits Label
End Control
Control ListBox1 Inherits ListBox
ControlInstance ListBox1 Inherits ListBox
End Control
Control sendbutton Inherits PushButton
ControlInstance sendbutton Inherits PushButton
EventHandler Sub Action() listbox1.AddRow EditField4.text sock.SendPacket ConvertEncoding(EditField4.text,encodings.utf8) EditField4.text="" End EventHandler
End Control
Control EditField4 Inherits TextField
ControlInstance EditField4 Inherits TextField
End Control
Control Sock Inherits PacketSocketMBS
ControlInstance Sock Inherits PacketSocketMBS
EventHandler Sub Connected() window1.StaticText3.text="Connected" window1.StaticText6.text="Connected" sendbutton.enabled=true End EventHandler
EventHandler Sub Error() if me.LastErrorCode=102 then // closed window1.StaticText3.text="Disconnected" window1.StaticText6.text="Disconnected" ConnectButton.Enabled=true listenButton.Enabled=true sendbutton.enabled=false else window1.StaticText3.text="Error "+str(me.LastErrorCode) window1.StaticText6.text="Error "+str(me.LastErrorCode) end if End EventHandler
EventHandler Sub ReceivedPacket(data as string,code as string,ID as integer) Listbox1.AddRow ">"+DefineEncoding(data,encodings.utf8) End EventHandler
End Control
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
End Project

The items on this page are in the following plugins: MBS Network Plugin.


The biggest plugin in space...