Question:
BBSDown is a mini webserver, I've parsed the GET command out of the client header and got thinking if a user had an image displayed in a forum, I couldalso send a JPG or GIF etc if I found the request to be FOR a gif/JPG etc.
So I've parsed the GET, determined whether it's requesting html or an image and I'd like to send the image to the client.
Now I assumed (bad word) that I could just binarily read the JPG into memory and transmit that out as a string, apparantly not, does not work..
Wha'ts the trick?
Here is the FD_READ code where I send the data:
BBSDown is a mini webserver, I've parsed the GET command out of the client header and got thinking if a user had an image displayed in a forum, I couldalso send a JPG or GIF etc if I found the request to be FOR a gif/JPG etc.
So I've parsed the GET, determined whether it's requesting html or an image and I'd like to send the image to the client.
Now I assumed (bad word) that I could just binarily read the JPG into memory and transmit that out as a string, apparantly not, does not work..
Wha'ts the trick?
Here is the FD_READ code where I send the data:
Code:
'ParseAndUpdateLogfile reads the client header in and gathers the info from that. 'IF lResult is FALSE then they requested html, otherwise an image (It's a start) lResult = ParseAndUpdateLogfile(ByVal sPacket,ByVal hTcp) 'Updates window ' <-------------Send data and disconnect-------------> Tcp Send hTcp, "HTTP/1.1 200" Tcp Send hTcp, "Server: " & g_szMine Tcp Send hTcp, "Date: " & GetPCTimeandDate() If IsFalse lResult Then 'html Tcp Send hTcp, g_BBSDown Tcp Send hTcp, "Content-Type: text/html" Tcp Send hTcp, "Content-Length: " & Format$(Len(g_BBSDown)) Else 'jpg Tcp Send hTcp, "Content-Type: image/jpeg" Tcp Send hTcp, "Content-Length: " & Format$(Len(g_BBSDownImage)) Tcp Send hTcp, g_BBSDownImage End If Tcp Close hTcp hTcp = %INVALID_SOCKET ' <-------------Send data and disconnect-------------> 'End connection here
Comment