⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmserver.class

📁 Gambas is a graphical development environment based on a Basic interpreter, like Visual Basic. It us
💻 CLASS
字号:
' Gambas class filePRIVATE UDPServer AS UdpSocketPUBLIC SUB Button1_Click()  DIM MyFrm AS FrmClient  MyFrm=NEW FrmClient  MyFrm.Visible=TRUE  END'//////////////////////////////////////////////////' Server Stuff'//////////////////////////////////////////////////PUBLIC SUB Button2_Click()  IF UDPServer.Status <= Net.Inactive THEN    UDPServer.Bind(Val(TextBox1.Text))    IF UDPServer.Status=Net.Active THEN      Button2.Text=("Stop")      TextBox1.Enabled=FALSE    END IF  ELSE    CLOSE #UDPServer    Button2.Text=("Start !")    TextBox1.Enabled=TRUE  END IF    ENDPUBLIC SUB Form_Open()  UDPServer=NEW UdpSocket AS "UDPServer"ENDPUBLIC SUB Form_Close()  IF UDPServer.Status >0 THEN CLOSE #UDPServerENDPUBLIC SUB UDPServer_Error()    Button2.Text="Start !"  TextBox1.Enabled=TRUE  SELECT CASE UDPServer.Status    CASE Net.CannotBindSocket      Message.Error(("Unable to Bind to that port"))    CASE Net.CannotCreateSocket      Message.Error(("System does not allow to create a socket"))    CASE Net.CannotRead      Message.Error(("Error Sending Data"))    CASE Net.CannotWrite      Message.Error(("Error Receiving Data"))  END SELECT  ENDPUBLIC SUB UDPServer_Read()    DIM sCadRet AS String  DIM sCad AS String  DIM MyLoop AS Integer   sCadRet=""  READ #UDPServer,sCad,Lof(UDPserver)  TextArea1.Text=TextArea1.Text &  ("Received data from : ") & UDPServer.SourceHost & ":" & UDPServer.SourcePort & Chr(13) & Chr(10)  TextArea1.Text=TextArea1.Text & ("Data --> ") & sCad & Chr(13) & Chr(10)  IF Len(sCad)>0 THEN    FOR myloop=Len(sCad) TO 1 STEP -1      sCadRet=sCadRet & Mid(sCad,myloop,1)    NEXT    UDPServer.TargetHost=UDPServer.SourceHost    UDPServer.TargetPort=UDPServer.SourcePort    WRITE #UDPServer,sCadRet,Len(sCadRet)  END IF  END

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -