HTTP server

tonelm54
tonelm54 used Ask the Experts™
on
Ive been asked to add a web component to one of my applications so users can add settings to the app from another pc by a web interface.

The gui works great, and I was happy with users just entering data on the software, but users needs must :-(

Ive been reading up on it, and belive I just need to listen on port 80, and serve content. My initail test code seems to pickup that someone is accessing the site, but I cant seem to get it to send the data to the web browser.

My code currently stands at:-
Imports System.Net.Sockets
Imports System.Net
Imports System.Text

Public Class Form1
    Dim ipAd As IPAddress
    Dim myList As TcpListener

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        myList = New TcpListener(IPAddress.Loopback, 80)

        myList.Start()

        Dim s As Socket = myList.AcceptSocket
        Debug.Print("Connection accepted from " & s.RemoteEndPoint.ToString)

        Dim asen As New ASCIIEncoding
        s.Send(asen.GetBytes("Recived."))

        s.Close()
    End Sub
End Class

Open in new window


Does anyone have any information on what I can do?

Thank you
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
if I were you, I'd go with webservices (or just services, depending on the implementation), like

http://www.freevbcode.com/ShowCode.asp?ID=4204
Most Valuable Expert 2012
Top Expert 2014
Commented:
while one could surely use sockets for that, I do believe WCF service could offer better options, see eg

http://stackoverflow.com/questions/5042135/adding-wcf-service-to-existing-application

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial