i dont think so because for when it requested a javascript i just sent the data for it to them and it worked but that wasnt binary data it was text.
i dont think so because for when it requested a javascript i just sent the data for it to them and it worked but that wasnt binary data it was text.
flamewavetech, you need to send an HTTP response header, as gxpark suggested.
ie. Someone requests a gif image from the server:You send that in a big chunk. The header is part of the HTTP protocol, and it is required. Post back if you need more information. Also, have you read the HTML 1.0 / 1.1 RFC? It might help you understand the requirements of the protocol.Quote:
HTTP/1.0 200 OK <crlf>
Content-Type: image/gif <crlf>
Content-Length: <length of binary content of gif image><crlf>
<crlf>
<binary content of gif file>
Laterz
now im trying this and it sill isnt working. its finding the file thought and it automaticly closes connection on sendcomplete.
Public Sub getitem(winsock As Integer, itempath As String)
Dim filenum As Integer
filenum = FreeFile
itempath = "C:\WINDOWS\Desktop\Kids Trivia\items\" & itempath
If Mid(itempath, Len(itempath) - 1, 2) = "js" Then
Dim data As String
Open itempath For Input As #filenum
data = Input(FileLen(itempath), #filenum)
Close #filenum
DoEvents
Form1.Winsock1(winsock).SendData data
DoEvents
Else
Dim data2 As Byte
Open itempath For Binary As #filenum
Get #filenum, , data2
Close #filenum
DoEvents
Form1.Winsock1(winsock).SendData "HTTP/1.0 200 OK" & vbCrLf & "Content-Type: image/gif" & vbCrLf & "Content-Length:" & FileLen(itempath) & vbCrLf & vbCrLf & data2
DoEvents
End If
End Sub
VB Code:
Public Sub getitem(winsock As Integer, itempath As String) Dim filenum As Integer filenum = FreeFile itempath = "C:\WINDOWS\Desktop\Kids Trivia\items\" & itempath If Mid(itempath, Len(itempath) - 1, 2) = "js" Then Dim data As String Open itempath For Input As #filenum data = Input(FileLen(itempath), #filenum) Close #filenum DoEvents Form1.Winsock1(winsock).SendData data DoEvents Else Dim data2 As Byte Open itempath For Binary As #filenum Get #filenum, , data2 Close #filenum DoEvents Form1.Winsock1(winsock).SendData "HTTP/1.0 200 OK" & vbCrLf & "Content-Type: image/gif" & vbCrLf & "Content-Length:" & FileLen(itempath) & vbCrLf & vbCrLf & data2 DoEvents End If End Sub
it still doesnt work.
Try this revised code:VB Code:
Public Sub getitem(winsock As Integer, itempath As String) Dim filenum As Integer Dim data As String 'Dim data2 As Byte '? filenum = FreeFile itempath = "C:\WINDOWS\Desktop\Kids Trivia\items\" & itempath If Mid(itempath, Len(itempath) - 1, 2) = "js" Then 'YOU SHOULD STILL SEND A BASIC HEADER FOR A .JS FILE 'i.e. 'Open itempath For Binary As #filenum 'data = Space(LOF(1)) 'Get #filenum, , data 'Close #filenum 'DoEvents 'Form1.Winsock1(winsock).SendData "HTTP/1.0 200 OK" & vbCrLf & "Content-Type:application/x-javascript" & vbCrLf & "Content-Length:" & Len(data) & vbCrLf & vbCrLf & data ' Open itempath For Input As #filenum data = Input(FileLen(itempath), #filenum) Close #filenum DoEvents Form1.Winsock1(winsock).SendData data DoEvents Else Open itempath For Binary As #filenum 'Just get the binary data in a string... dont worry bout byte arrays etc data = Space(LOF(1)) Get #filenum, , data Close #filenum DoEvents Form1.Winsock1(winsock).SendData "HTTP/1.0 200 OK" & vbCrLf & "Content-Type: image/gif" & vbCrLf & "Content-Length:" & Len(data) & vbCrLf & vbCrLf & data DoEvents End If End Sub
Hope this helps. Also, download and read the HTTP RFC... :)
Laterz