|
-
Jun 25th, 1999, 12:35 AM
#1
Thread Starter
Lively Member
how do you have the winsock control for use as a webserver??
-
Jul 4th, 1999, 12:04 AM
#2
New Member
Hello, I wouldn't have the foggiest idea, but here's a cloudy one:
Winsock.localport = 80
Winsock.listen
whenever something connects
accept the connection & send the strings of a html file e.g.
Dim file as string
file = "<html><body><h1>HI THERE</h1></body></html>"
Winsock.senddata file
Hope this works 4 u, might need some shaving 
- Wax
-
Jul 4th, 1999, 11:15 AM
#3
Fanatic Member
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/
-
Jul 5th, 1999, 10:51 AM
#4
New Member
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
-
Aug 9th, 1999, 08:32 AM
#5
New Member
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|