Results 1 to 6 of 6

Thread: is there any specific format for respondin to a explorers request for a picture?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2001
    Posts
    746
    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.

  2. #2
    Fanatic Member
    Join Date
    Sep 2000
    Location
    UK.
    Posts
    728

    Smile 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]

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2001
    Posts
    746
    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

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2001
    Posts
    746
    VB Code:
    1. Public Sub getitem(winsock As Integer, itempath As String)
    2. Dim filenum As Integer
    3. filenum = FreeFile
    4. itempath = "C:\WINDOWS\Desktop\Kids Trivia\items\" & itempath
    5. If Mid(itempath, Len(itempath) - 1, 2) = "js" Then
    6. Dim data As String
    7. Open itempath For Input As #filenum
    8. data = Input(FileLen(itempath), #filenum)
    9. Close #filenum
    10. DoEvents
    11. Form1.Winsock1(winsock).SendData data
    12. DoEvents
    13. Else
    14. Dim data2 As Byte
    15. Open itempath For Binary As #filenum
    16. Get #filenum, , data2
    17. Close #filenum
    18. DoEvents
    19. Form1.Winsock1(winsock).SendData "HTTP/1.0 200 OK" & vbCrLf & "Content-Type: image/gif" & vbCrLf & "Content-Length:" & FileLen(itempath) & vbCrLf & vbCrLf & data2
    20.  
    21. DoEvents
    22. End If
    23. End Sub

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2001
    Posts
    746
    it still doesnt work.

  6. #6
    Fanatic Member
    Join Date
    Sep 2000
    Location
    UK.
    Posts
    728

    Smile Info.

    Try this revised code:
    VB Code:
    1. Public Sub getitem(winsock As Integer, itempath As String)
    2.     Dim filenum As Integer
    3.     Dim data As String
    4.     'Dim data2 As Byte '?
    5.  
    6.     filenum = FreeFile
    7.     itempath = "C:\WINDOWS\Desktop\Kids Trivia\items\" & itempath
    8.  
    9.     If Mid(itempath, Len(itempath) - 1, 2) = "js" Then
    10.         'YOU SHOULD STILL SEND A BASIC HEADER FOR A .JS FILE
    11.         'i.e.
    12.         'Open itempath For Binary As #filenum
    13.         'data = Space(LOF(1))
    14.         'Get #filenum, , data
    15.         'Close #filenum
    16.         'DoEvents
    17.         'Form1.Winsock1(winsock).SendData "HTTP/1.0 200 OK" & vbCrLf & "Content-Type:application/x-javascript" & vbCrLf & "Content-Length:" & Len(data) & vbCrLf & vbCrLf & data
    18.         '
    19.  
    20.         Open itempath For Input As #filenum
    21.         data = Input(FileLen(itempath), #filenum)
    22.         Close #filenum
    23.         DoEvents
    24.         Form1.Winsock1(winsock).SendData data
    25.         DoEvents
    26.     Else
    27.  
    28.         Open itempath For Binary As #filenum
    29.         'Just get the binary data in a string... dont worry bout byte arrays etc
    30.         data = Space(LOF(1))
    31.         Get #filenum, , data
    32.         Close #filenum
    33.         DoEvents
    34.         Form1.Winsock1(winsock).SendData "HTTP/1.0 200 OK" & vbCrLf & "Content-Type: image/gif" & vbCrLf & "Content-Length:" & Len(data) & vbCrLf & vbCrLf & data
    35.  
    36.         DoEvents
    37.     End If
    38. 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
  •  



Click Here to Expand Forum to Full Width