Jump to content
  • Advertisement
Sign in to follow this  
Nice Coder

Writing a simple webserver

This topic is 4833 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've been thinking about making a very simple webserver. I can't seem to get it working. (in vb). Mozilla isn't sending any requests. It connects, then it just times out. (and says 'the document contains no data'. I connect to telnet, and it just pops up with a 'connection to host lost' thing basically instantly. Does anybody have any information that can shed some light in it? I currently have two winsock controls and come really basic debugging code.
Private Sub Form_Load()
Winsock1.Listen
Me.Hide
End Sub

Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
Winsock1.Close
Winsock1.Connect requestID
'Winsock2.Connect requestID
DoEvents
End Sub

Private Sub Winsock2_Connect()
Debug.Print "Winsock2 connected"
End Sub

Private Sub Winsock2_ConnectionRequest(ByVal requestID As Long)
Debug.Print requestID
End Sub

Private Sub Winsock2_DataArrival(ByVal bytesTotal As Long)
Dim s As String
Winsock1.GetData s, vbString, bytesTotal
Debug.Print s
End Sub

I've tried everything i can think of, but it just isn't connecting! ARGGG! From, Nice coder

Share this post


Link to post
Share on other sites
Advertisement
Hi,

I think it times out, because you aren't replying on the request.
It sends GET .... and is waiting for an answer, the html document.
In your code there is no reply function.

Marc

Share this post


Link to post
Share on other sites
It doesn't particularly matter, because:

1. It times out instantly. (it doesn't do anything. Even when i connect via telnet, it looses connection instantly) and

2. It isn't connecting. At all. It goes through the connection code, but it doesn't connect.

and

3. It isn't recieving any data. At all.

From,
nice coder

Share this post


Link to post
Share on other sites
I haven't written any VB networking code in a long time, but shouldn't you be calling


Winsock1.accept requestID



in Winsock1_ConnectionRequest, rather than Winsock1.Connect? Also, have you set the port number to be listening on? In code you could write


Winsock1.LocalPort = 80



Just before calling Winsock1.Listen.

Alan

Share this post


Link to post
Share on other sites
Quote:
Original post by Alan Kemp
I haven't written any VB networking code in a long time, but shouldn't you be calling

*** Source Snippet Removed ***

in Winsock1_ConnectionRequest, rather than Winsock1.Connect? Also, have you set the port number to be listening on? In code you could write

*** Source Snippet Removed ***

Just before calling Winsock1.Listen.

Alan


Spoke too soon.
It recieves the request, but mozilla isn't doing anything. (it times out)

Rate++ anyway

From,
Nice coder

Share this post


Link to post
Share on other sites
Quote:
Original post by Drew_Benton
If you don't mind looking a few examples...
Link 1 | Link 2 | Link 3 | Link 4

Now after 5 views of code, you will have to register, but that site is the best [grin]. See if any of those can help you figre out what the problem is.


Thanks. I've already seen planetsourcecode. (and i have an account, assuming they haven't gotten rid of it.)

Now, does anybody have any idea on how to send things like images, ect?

From,
Nice coder

Share this post


Link to post
Share on other sites
Ok, its working. (thanks drew :) i needed those egsamples. Turns out i was missing a doevents before i was closing the socket).

Now, how would i do images?

From,
nice coder

Share this post


Link to post
Share on other sites
Got directory listings to work.


<html><head><title>Directory list of /Web</title></head>
Directory listing of /Web<br>Made by Armada Server<hr>
Directories: <hr><a href='Web/Folder'>Folder</a><br>
<hr> Files <hr> <a href='Web/Something.txt'>Something.txt</a><br>
<a href='Web/Somethingelse.txt'>Somethingelse.txt</a><br>



Looks really good :).

From,
Nice coder

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!