I have a very small vb.net program that has a message box and submit button! just for demonstration when for example send "Hi" it replies with "how are you" ( again, just for demonstration. If it were such as simple, I'd convert the code to PHP ). I want this program to listen on some port in my Ubuntu server that runs Nginx. and Instead of having an input box and a button It'd just accept incoming strings and send the reply string back to the client.
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:
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
- References ( creating the server ) :
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