在Ubuntu服务器上运行Vb.net程序 [英] Run Vb.net Program on Ubuntu Server
问题描述
我有一个非常小的vb.net程序,带有一个消息框和提交按钮!仅用于演示,例如,发送"Hi"时,它会回复您好吗"(再次用于演示.如果很简单,我会将代码转换为PHP).我希望该程序在运行Nginx的Ubuntu服务器中的某个端口上进行侦听.而不是具有输入框和按钮,它只接受传入的字符串并将回复字符串发送回客户端.
我尝试创建服务器程序,然后使用Mono在我的小型服务器上运行它.但是,即使在我的计算机上,此代码(服务器端)也无法使用:
Dim msg As String
Dim Data As String
Do Until isListining = False
If server.Pending = True Then
Client = server.AcceptTcpClient
Data = New StreamReader(Client.GetStream).ReadToEnd()
msg = "" ' HERE I handle the Data and return the reply message
Dim bytes() As Byte = System.Text.ASCIIEncoding.ASCII.GetBytes(msg)
Client.GetStream.Write(bytes, 0, bytes.Length)
Client.Client.Send(System.Text.UTF8Encoding.UTF8.GetBytes(msg))
Client.Close()
End If
Thread.Sleep(100)
Loop
- 参考(创建服务器):
VB.NET教程-客户端/服务器网络编程-简单聊天应用程序 >
我已经设法通过将代码转换为Python来解决问题,它可以在Ubuntu服务器上运行.然后我设法运行了简单HTTP服务器,然后导入了我的代码.>
有关该主题的更多信息,请关注此线程:
I tried creating the server program then Run it on my small Server using Mono. But this code ( server side ) wasn't working even on my computer:
VB.NET Tutorial - Client / Server Network Programming - Simple Chat Application A Peer-To-Peer LAN Chat Application in Visual Basic.Net using TcpClient and TcpListener This code has problem with sending back the respond to the client. I want to know if There's an easy way to directly run it on the server. and if not, then where's the problem on my code ? Thanks in advance. NB: I found a lot of examples about running a local server but most of them also didn't work and add them in the references tab would be quite a list :D I have managed to fix my problem by converting my code to Python this way It can run on my Ubuntu Server. and then I've managed to run a Simple HTTP Server and then importing my code. for more information if you were interested about the topic, please follow this thread : REST API framework that works with my python program instead of Database 这篇关于在Ubuntu服务器上运行Vb.net程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! Dim msg As String
Dim Data As String
Do Until isListining = False
If server.Pending = True Then
Client = server.AcceptTcpClient
Data = New StreamReader(Client.GetStream).ReadToEnd()
msg = "" ' HERE I handle the Data and return the reply message
Dim bytes() As Byte = System.Text.ASCIIEncoding.ASCII.GetBytes(msg)
Client.GetStream.Write(bytes, 0, bytes.Length)
Client.Client.Send(System.Text.UTF8Encoding.UTF8.GetBytes(msg))
Client.Close()
End If
Thread.Sleep(100)
Loop