|
-
Oct 20th, 2001, 12:09 PM
#1
Thread Starter
Fanatic Member
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.
-
Oct 20th, 2001, 05:02 PM
#2
Fanatic Member
Info.
flamewavetech, you need to send an HTTP response header, as gxpark suggested.
ie. Someone requests a gif image from the server:
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>
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.
Laterz
Digital-X-Treme
Contact me on MSN Messenger: [email protected]
[VBCODE]Debug.Print Round(((1097) - ((55 ^ 5 + 311 ^ 3 - 11 ^ 3) _
/ (68 ^ 5))) ^ (1 / 7), 13)[/VBCODE]
-
Oct 20th, 2001, 06:08 PM
#3
Thread Starter
Fanatic Member
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
-
Oct 20th, 2001, 06:08 PM
#4
Thread Starter
Fanatic Member
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
-
Oct 21st, 2001, 11:54 AM
#5
Thread Starter
Fanatic Member
-
Oct 21st, 2001, 03:57 PM
#6
Fanatic Member
Info.
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
Digital-X-Treme
Contact me on MSN Messenger: [email protected]
[VBCODE]Debug.Print Round(((1097) - ((55 ^ 5 + 311 ^ 3 - 11 ^ 3) _
/ (68 ^ 5))) ^ (1 / 7), 13)[/VBCODE]
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
|