that probably won't work. i have compleatly written a webserver already. try control.localport = 80 control.listen
Private Sub control_ConnectRequest(RequestId as whatever) control.close control.Accept RequestId
End Sub
Private Sub control_DataArrival(Length as whatever) control.SendData YourData
End Sub
Private Sub control_SendComplete() control.Close
Ens Sub
This is a modified version of my code. I might recommend using a control array so as you can have multiple connections simultaniously. For more info on the HTTP protocal goto http://www.jmarshall.com/easy/http/
For mutliple connections, the best way to do it is this: Say you are using a Winsock control named Winsock1, which is the control listening for a connection request. Give that an index value of 0, so it is Winsock1(0). Give all other connections of that winsock control incremental Indexes...a way to show that in code is:
Option Explicit
Const conPort as Integer = 80
Private Sub Form_Load()
Winsock1(0).LocalPort = conPort
Winsock1(0).Listen
End Sub
Private Sub Winsock1_ConnectionRequest(Index as Integer)
Const conPort as Integer = 80
Static intMax as Integer
If Index = 0 Then
intMax = intMax + 1
Load Winsock2(intMax)
Winsock2(intMax).LocalPort = conPort
Winsock2(intMax).Accept requestID
End If
End Sub
If a connection ever closes, remember to do something like this to ensure that the winsock control can be used again for that number if you reset your server.
Private Sub Winsock1_Close(Index as Integer)
Unload Winsock1(Index)
End Sub
Here is my code, but it doesn't work... PLEASE help...
Private Sub Form_Load()
Winsock1.LocalPort = 80
Winsock1.Listen
End Sub
Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
Winsock1.Close
Winsock1.Accept requestID
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim MyData As String
MyData = "IT WORKS!!!"
MyData = MyData & vbCrLf & "<br>The time is now " & Time$
Winsock1.SendData MyData
End Sub
Private Sub Winsock1_SendComplete()
Winsock1.Close
End Sub