Blog : InternetReadFile For Servlets (streaming)?????
InternetReadFile For Servlets (streaming)?????
Sup all,
I am using InternetReadFile for reading the code foe web pages into a buffer. But I have run into a problem since I need to read in data from a servlet that is streaming data. Since there is no EOF InternetReadFile continues to try to find it and will never return. I sifted through some of the info databases on Microsoft's site, but I haven't found any alternatives yet. I'll keeps diggin', but I was hoping maybe one of you guyz might know.
TIA!
-cLocKwOrk[Edited by cLocKwOrk on 01-03-2001 at 09:50 PM]
View Complete Forum Thread with Replies
--------------------------------------------------------------------------------
See Related Forum Messages: Follow the Links Below to View Complete Thread
--------------------------------------------------------------------------------
•Accessing VB From Servlets
•Streaming Pixels (Byte) From Parallel && Display In VB As Video Streaming
•InternetReadFile
•InternetOpenUrl, InternetReadFile, Etc.
•Getting Corrupted XML Using InternetReadFile
•InternetReadFile Problem
•Alternatives To InternetReadFile??
•InternetReadFile Hangs Up Sometimes
•InternetReadFile Problem
•InternetQueryDataAvailable, InternetReadFile And InternetStatusCallback
•WININET: InternetReadFile Crashes VB
•Wininet Hangs On InternetReadFile
•InternetReadFile Doesn't Read...
•InternetReadFile...eMbedded Visual Basic
•Internetreadfile Function Corrupts Files
•How Can I Download A Binary File Use 'InternetReadFile' In HTTP
•InternetOpenURL(), InternetReadFile() Problem... Download Running Away (wininet Dll)
•File Download Using InternetReadFile Corrupts File Contents
•RTP Streaming In VB ?
•STREAMING MP3 Possible?
•Help With Streaming
•Streaming...
•Streaming
•MP3 - Streaming Over Net
•Streaming MP3 Over A Lan
•Streaming MP3 Over A Lan
•Streaming
•Streaming Mp3 In VB 6
•GDI+ Example 6 Streaming Bitmaps
•Video Streaming
•Streaming Zip Files?
•Video Streaming In Vb6
•MPEG2 Streaming
•Streaming With DirectShow Help...
•Sound Streaming
•Streaming Audio
•RealTime Streaming
•Streaming Data
•Streaming MP3 Data
•Msdxm, Wmp.dll And Streaming
•Streaming Audio
•Streaming Webcam
•Streaming Array
•Video Streaming
•Sound Streaming
•Streaming Audio In VB?
•Streaming Data
•Streaming Video
•Data Streaming
Accessing VB From Servlets
hai,
is it possible to access a VB application from a servlet.if so how.thanx.
qs
--------------------------------------------------------------------------------
Streaming Pixels (Byte) From Parallel && Display In VB As Video Streaming
Help me please
I want get pixels (byte) from camera module (parallel interface) and display them to VB as video streaming with 25 fps
Thanks
ss_gober
--------------------------------------------------------------------------------
InternetReadFile
Hi,
I'm writing an app that uses a number of API calls. Essentially I create a file, read the contents of an internet page (wininet's InternetReadFile API) and write it to the file. Creating the file works, reading the contents works but writting them doesn't. For each loop, I'm passing new data into the buffer and it appears to work (using debug.print) but when I go and open the new file it is something like: `É DÃ… TÊ8 0ó Λ ÂÂmË
over and over. I can sucessfully write the contents out using debug.print but the newly created files gives completely different results. I just don't see what is the problem. Does anyone have any ideas? Is there a better way to write out the contents of the buffer to a file?
strFilePath = "C:Tempfile.txt"
hFile = CreateFile(strFilePath, GENERIC_READ Or GENERIC_WRITE, FILE_SHARE_READ Or FILE_SHARE_WRITE, _
ByVal 0&, CREATE_ALWAYS, 0, ByVal 0&)
If hFile > 0 Then
'get length of buffer
dwLength = 1024
strBuffer = Space(1024)
Do While InternetReadFile(hInternetConnect, strBuffer, dwLength, dWritten)
If dWritten <> 0 Then
iRetVal = WriteFile(hFile, strBuffer, dWritten, dwSize, vbNullString)
If iRetVal = 0 Then
CloseHandle (hFile)
'report error
End If
Else
'read file complete
Exit Do
End If
Loop
Else
CloseHandle (hFile)
'report error
End If
CloseHandle (hFile)
--------------------------------------------------------------------------------
InternetOpenUrl, InternetReadFile, Etc.
I was using Winsock to get web pages from the Internet, but there's a bug somewhere that frequently causes pages to be incomplete. MicroSoft's solution is to use the Windows API functions (InternetOpen, InternetOpenUrl, etc.) which I now do, and every page comes through ok. But there's a problem...
I need to parse each page's header for 200s, 404s, 302s, etc. but the Windows API functions don't return the header. In fact they act on 302s (location moved) and automatically get the page from the new location, so I've no way of knowing that a 302 page was returned.
One solution is to get each page twice - once with WinSock and again using the API, but that's a horrible of way of doing it.
Is there any way that I can use the API functions and actually get the first returned page, with its header, instead of the API going off and getting another page?
--------------------------------------------------------------------------------
Getting Corrupted XML Using InternetReadFile
Hello,
I am using a embedded VB function here and it is giving me corrupted XML data( throwing extra characters). Here is the code: any suggestions?
Public Function sendRequestReadResponse(hOpenRequest As Long) As String
Dim moreData As Boolean
Dim bufferDataFromResponse As String
Dim numberOfBytesRead As Long
Dim numberOfBytesToRead As Long
Dim dataFromResponse As String
moreData = True
numberOfBytesToRead = 2048
dataFromResponse = ""
sendRequestToServer (hOpenRequest)
While moreData
bufferDataFromResponse = String(numberOfBytesToRead, " ")
moreData = InternetReadFile(hOpenRequest, _
bufferDataFromResponse, _
numberOfBytesToRead, _
numberOfBytesRead)
If numberOfBytesRead > 0 Then
dataFromResponse = dataFromResponse & Trim(bufferDataFromResponse)
Else
'break out of the loop
moreData = False
End If
Wend
sendRequestReadResponse = dataFromResponse
End Function
Thanks much
--------------------------------------------------------------------------------
InternetReadFile Problem
Hi all,
I trying to download file from ftp server using internetreadfile. I'm trying to download the files in chunks, so that I can update the progress on to the screen.
this code is working fine except the file size it downloads. I downloaded a file of 97 KB(98954 bytes) and created a file of size 1.93 MB (2027520 bytes).
Why is it so? Please help.
my code follows:
' Open local file for writing
Dim F1 As Integer, j As Integer, sum As Long
F1 = FreeFile
Open szFileLocal & "" & szFileRemote For Binary As F1
Size = 98954 'filesize of remote
bDoLoop = True
For j = 1 To Size 100
sReadBuffer = vbNullString
' Read data from data connection
bDoLoop = InternetReadFile(hFile, sReadBuffer, 100, lNumberOfBytesRead)
' Save received data to local file
Put F1, , sReadBuffer
If Not CBool(lNumberOfBytesRead) Then Exit For
DoEvents
sum = sum + 100
DoEvents
Next j
If Size Mod 100 <> 0 Then
sReadBuffer = vbNullString
' Read data from data connection
bDoLoop = InternetReadFile(hFile, sReadBuffer, Size Mod 100, lNumberOfBytesRead)
' Save received data to local file
Put F1, , sReadBuffer
If Not CBool(lNumberOfBytesRead) Then MsgBox "Error in retrieving the image", vbInformation, "Alert"
End If
sum = sum + (Size Mod 100)
' Close local file
Close F1
Thanks
M.L.Srinivas
--------------------------------------------------------------------------------
Alternatives To InternetReadFile??
Hi all,
I was wondering is any of you knew an alternative API to InternetReadFile. I am currently using it with some success, but the only problem that I can see with it is that there is no timeout when hit a web page... so if its down the call never returns.
I know there is a InternetReadFileRev that allows you to specify the timeout, but the only problem with it is that it doesn't return the # of bytes read in. (So if I send it a 32byte buffer and it only reads in 20bytes, I want to know since the rest of the buffer will be filled with garbage).
My code looks something like this:
Code:
Public Function justReturnWholePageString(passedURL As String) As String
Dim newlinePosition As Integer
Dim hOpen As Long
Dim hOpenUrl As Long
Dim sUrl As String
Dim LineBuffer As String
Dim bDoLoop As Boolean
Dim bRet As Boolean
Dim sReadBuffer As String * 2048
Dim lNumberOfBytesRead As Long
Dim sBuffer As String
sUrl = passedURL
LineBuffer = ""
testLineCounter = 0
hOpen = InternetOpen(scUserAgent, INTERNET_OPEN_TYPE_PRECONFIG, vbNullString, vbNullString, 0)
hOpenUrl = InternetOpenUrl(hOpen, sUrl, vbNullString, 0, INTERNET_FLAG_RELOAD, 0)
bDoLoop = True
Application.ScreenUpdating = True
While (bDoLoop)
sReadBuffer = vbNullString
bRet = InternetReadFile(hOpenUrl, sReadBuffer, Len(sReadBuffer), lNumberOfBytesRead)
LineBuffer = LineBuffer & sReadBuffer
sBuffer = sBuffer & Left$(sReadBuffer, lNumberOfBytesRead)
If Not CBool(lNumberOfBytesRead) Then
bDoLoop = False
End If
Wend
justReturnWholePageString = sBuffer
If hOpenUrl <> 0 Then InternetCloseHandle (hOpenUrl)
If hOpen <> 0 Then InternetCloseHandle (hOpen)
End Function
Can anyone suggest an alternative for me?
TIA!
--------------------------------------------------------------------------------
InternetReadFile Hangs Up Sometimes
I am using the InternetReadFile function to get the content of a webpage. It runs successfully most of the time, but on one machine its hang up. On that machine too, it is capturing 10-15 pages then its is hanging.
I am using VB6.0 and the following code
Dim hOpen As Long
Dim hOpenUrl As Long
Dim bDoLoop As Boolean
Dim bRet As Boolean
Dim sReadBuffer As String * 2048
Dim lNumberOfBytesRead As Long
Dim sBuffer As String
Dim bSetOption As Boolean
Dim lngTimeout As Long
lngTimeout = 60000
lByteTransferred = 0
hOpen = InternetOpen(scUserAgent, INTERNET_OPEN_TYPE_PRECONFIG, vbNullString, vbNullString, 0)
If hOpen = 0 Then
Exit Function
End If
bSetOption = InternetSetOption(hOpen, INTERNET_OPTION_CONNECT_TIMEOUT, lngTimeout, 4)
bSetOption = InternetSetOption(hOpen, INTERNET_OPTION_RECEIVE_TIMEOUT, lngTimeout, 4)
bSetOption = InternetSetOption(hOpen, INTERNET_OPTION_SEND_TIMEOUT, lngTimeout, 4)
bSetOption = InternetSetOption(hOpen, INTERNET_OPTION_CONTROL_RECEIVE_TIMEOUT, lngTimeout, 4)
bSetOption = InternetSetOption(hOpen, INTERNET_OPTION_CONTROL_SEND_TIMEOUT, lngTimeout, 4)
bSetOption = InternetSetOption(hOpen, INTERNET_OPTION_DATA_RECEIVE_TIMEOUT, lngTimeout, 4)
bSetOption = InternetSetOption(hOpen, INTERNET_OPTION_DATA_SEND_TIMEOUT, lngTimeout, 4)
hOpenUrl = InternetOpenUrl(hOpen, sUrl, vbNullString, 0, INTERNET_FLAG_RELOAD, 0)
If hOpenUrl = 0 Then
Exit Function
End If
bDoLoop = True
While bDoLoop
sReadBuffer = vbNullString
bRet = InternetReadFile(hOpenUrl, sReadBuffer, Len(sReadBuffer), lNumberOfBytesRead)
sBuffer = sBuffer & Left$(sReadBuffer, lNumberOfBytesRead)
If Not CBool(lNumberOfBytesRead) Then bDoLoop = False
'RaiseEvent BytesTransferred(lNumberOfBytesRead)
lByteTransferred = lByteTransferred + lNumberOfBytesRead
Wend
If hOpenUrl <> 0 Then
Call InternetCloseHandle(hOpenUrl)
End If
If hOpen <> 0 Then
Call InternetCloseHandle(hOpen)
End If
Can any one has its solution
--------------------------------------------------------------------------------
InternetReadFile Problem
Hi all,
I trying to download file from ftp server using internetreadfile. I'm trying to download the files in chunks, so that I can update the progress on to the screen.
this code is working fine except the file size it downloads. I downloaded a file of 97 KB(98954 bytes) and created a file of size 1.93 MB (2027520 bytes).
Why is it so? Please help.
my code follows:
' Open local file for writing
Dim F1 As Integer, j As Integer, sum As Long
F1 = FreeFile
Open szFileLocal & "" & szFileRemote For Binary As F1
Size = 98954 'filesize of remote
bDoLoop = True
For j = 1 To Size 100
sReadBuffer = vbNullString
' Read data from data connection
bDoLoop = InternetReadFile(hFile, sReadBuffer, 100, lNumberOfBytesRead)
' Save received data to local file
Put F1, , sReadBuffer
If Not CBool(lNumberOfBytesRead) Then Exit For
DoEvents
sum = sum + 100
DoEvents
Next j
If Size Mod 100 <> 0 Then
sReadBuffer = vbNullString
' Read data from data connection
bDoLoop = InternetReadFile(hFile, sReadBuffer, Size Mod 100, lNumberOfBytesRead)
' Save received data to local file
Put F1, , sReadBuffer
If Not CBool(lNumberOfBytesRead) Then MsgBox "Error in retrieving the image", vbInformation, "Alert"
End If
sum = sum + (Size Mod 100)
' Close local file
Close F1
Thanks
M.L.Srinivas
--------------------------------------------------------------------------------
InternetQueryDataAvailable, InternetReadFile And InternetStatusCallback
Hi,
I was using InternetReadFile() with a fixed "NumBytesToRead". My InternetStatusCallback() implementation was working ok (events detected).
Now I'm using InternetQueryDataAvailable() before every call to InternetReadFile() to optimize the transfers. That works nice, but the InternetStatusCallback() routine is not being called anymore.
I've just noticed the Callback is called only when the amount of data to be read is bigger than the amount of data available. Is there a explanation for this? Is there a way to overcome this limitation/behavior?
10x
--------------------------------------------------------------------------------
WININET: InternetReadFile Crashes VB
In the following code, whenever VB attempts to execute the InternetReadFile line, Visual Basic crashes with an Access Violation. I couldn't see anything glaringly wrong with my code, but this is my first time working with the WININET API and I am unsure of myself.
Any help proffered would be greatly appreciated.
Code:
Dim hInternetOpen As Long
Dim hInternetConnect As Long
Dim hHttpOpenRequest As Long
Dim sHeader As String
Dim bResult As Boolean
Dim lpszPostData As String
Dim lPostDataLen As Long
Dim sBuffer As String
Dim sReadBuffer As String * 2048
Dim bDoLoop As Boolean
Dim lNumberOfBytesRead As Long
hInternetOpen = InternetOpen("PestPac.NET", _
INTERNET_OPEN_TYPE_PRECONFIG, _
vbNullString, _
vbNullString, _
0)
hInternetConnect = InternetConnect(hInternetOpen, _
"www.secure-site-address.com", _
INTERNET_DEFAULT_HTTPS_PORT, _
vbNullString, _
"HTTP/1.1", _
INTERNET_SERVICE_HTTP, _
0, _
0)
hHttpOpenRequest = HttpOpenRequest(hInternetConnect, _
"POST", _
"/directory/target.asp", _
"HTTP/1.1", _
vbNull, _
vbNull, _
INTERNET_FLAG_RELOAD Or INTERNET_FLAG_SECURE Or INTERNET_FLAG_IGNORE_CERT_CN_INVALID Or INTERNET_FLAG_IGNORE_CERT_DATE_INVALID, _
0)
sHeader = "Content-Type: multipart/form-data; boundary=--913114112" & vbCrLf
bResult = HttpAddRequestHeaders(hHttpOpenRequest, _
sHeader, Len(sHeader), HTTP_ADDREQ_FLAG_REPLACE _
Or HTTP_ADDREQ_FLAG_ADD)
sHeader = "Authorization: Basic " & Base64Encode("username:password") & vbCrLf
bResult = HttpAddRequestHeaders(hHttpOpenRequest, _
sHeader, Len(sHeader), HTTP_ADDREQ_FLAG_REPLACE _
Or HTTP_ADDREQ_FLAG_ADD)
lpszPostData = "--913114112" & vbNewLine & "Content-Disposition: " & _
"multipart/form-data; name=""Field""" & vbNewLine & vbNewLine & _
"Value" & vbNewLine & "--913114112--"
lPostDataLen = Len(lpszPostData)
bResult = HttpSendRequest(hHttpOpenRequest, _
vbNullString, _
0, _
lpszPostData, _
lPostDataLen)
bDoLoop = True
While bDoLoop
sReadBuffer = vbNullString
bResult = InternetReadFile(hHttpOpenRequest, sReadBuffer, Len(sReadBuffer), lNumberOfBytesRead)
sBuffer = sBuffer & Left$(sReadBuffer, lNumberOfBytesRead)
If Not CBool(lNumberOfBytesRead) Then bDoLoop = False
Wend
bResult = InternetCloseHandle(hHttpOpenRequest)
bResult = InternetCloseHandle(hInternetConnect)
bResult = InternetCloseHandle(hInternetOpen)
Everything up until the InternetReadFile line runs successfully. hHttpOpenRequest is a valid handle, and was used in the HttpSendRequest call (which returned successfully). And then I get the Access Violation crash.
Thanks again,
Joe Marino
--------------------------------------------------------------------------------
Wininet Hangs On InternetReadFile
Could you pls help me? There must be some problem with wininet.dll (bug?) since sometimes my program hangs on internetreadfile and the CPU usage is about 100%.
Here is my code (the problematic line is marked red) :
Code:
Const INTERNET_OPEN_TYPE_PRECONFIG = 0
Const INTERNET_FLAG_EXISTING_CONNECT = &H20000000
Private Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" _
(ByVal lpszAgent As String, ByVal dwAccessType As Long, _
ByVal lpszProxyName As String, ByVal lpszProxyBypass As String, _
ByVal dwFlags As Long) As Long
Private Declare Function InternetOpenUrl Lib "wininet.dll" Alias _
"InternetOpenUrlA" (ByVal hInternetSession As Long, ByVal lpszUrl As String, _
ByVal lpszHeaders As String, ByVal dwHeadersLength As Long, _
ByVal dwFlags As Long, ByVal dwContext As Long) As Long
Private Declare Function InternetCloseHandle Lib "wininet.dll" (ByVal hInet As _
Long) As Integer
Private Declare Function InternetReadFile Lib "wininet.dll" (ByVal hFile As _
Long, ByVal lpBuffer As String, ByVal dwNumberOfBytesToRead As Long, _
lNumberOfBytesRead As Long) As Integer
' Download a file from the Internet and save it to a local file
'
' it works with HTTP and FTP, but you must explicitly include
' the protocol name in the URL, as in
' CopyURLToFile "http://www.vb2themax.com/default.asp", "C:vb2themax.htm"
Function changeUrl(URL As String) As String
If Mid(URL, 8, 3) <> "www" Then
changeUrl = Left(URL, 7) + "www." + Mid(URL, 8, Len(URL))
Else
changeUrl = URL
End If
End Function
Sub CopyURLToFile(ByVal URL As String, ByVal FileName As String)
Dim hInternetSession As Long
Dim hUrl As Long
Dim FileNum As Integer
Dim ok As Boolean
Dim NumberOfBytesRead As Long
Dim BUFFER As String
Dim fileIsOpen As Boolean
On Error GoTo errorhandler
URL = changeUrl(URL)
If btSend(URL) = False Then GoTo errorhandler
' ensure that there is no local file
On Error Resume Next
Kill FileName
On Error GoTo errorhandler
' open the local file
FileNum = FreeFile
Open FileName For Binary As FileNum
fileIsOpen = True
' prepare the receiving buffer
BUFFER = Space(4096)
Do
' read a chunk of the file - returns True if no error
ok = InternetReadFile(hHttpOpenRequest, BUFFER, Len(BUFFER), NumberOfBytesRead)
' exit if error or no more data
If NumberOfBytesRead = 0 Or Not ok Then Exit Do
' save the data to the local file
Put #FileNum, , Left$(BUFFER, NumberOfBytesRead)
Loop
' flow into the error handler
errorhandler:
' close the local file, if necessary
If fileIsOpen Then
Close #FileNum
Else
FileNum = FreeFile
' On Error Resume Next
Open FileName For Output As FileNum
Print #FileNum, ""
Close #FileNum
End If
' close internet handles, if necessary
If hUrl Then InternetCloseHandle hUrl
If hInternetSession Then InternetCloseHandle hInternetSession
' report the error to the client, if there is one
'If Err Then
'Err.Raise Err.Number, , Err.Description
End Sub
--------------------------------------------------------------------------------
InternetReadFile Doesn't Read...
Hi All!
I'm working with eVB 3.0...WinInet's InternetReadFile function aint working, all goes well till HttpOpenRequest and HttpSendRequest, but when I say InternetReadfile, the function always returns an empty string in the string buffer...even though the last function parameter for total number of bytes read, reads the correct number of bytes...but god knows where the read string gets placed, atleast not in the function's assigned string parameter for the same...
Is there some difference in the signature or interpretation of this function for Windows CE??? What could be wrong??
Please reply back the earliest
Regards,
Sonia.
--------------------------------------------------------------------------------
InternetReadFile...eMbedded Visual Basic
Hi All!
I'm working with eVB 3.0...WinInet's InternetReadFile function aint working, all goes well till HttpOpenRequest and HttpSendRequest, but when I say InternetReadfile, the function always returns an empty string in the string buffer...even though the last function parameter for total number of bytes read, reads the correct number of bytes...but god knows where the read string gets placed, atleast not in the function's assigned string parameter for the same...
Is there some difference in the signature or interpretation of this function for Windows CE??? What could be wrong??
Please reply back the earliest
Regards,
Sonia
--------------------------------------------------------------------------------
Internetreadfile Function Corrupts Files
has anyone had a similiar issue with InternetReadFile function ?
I am enumerating a folder on the FTP server and then passing each file to the InternetReadFile funtion.. All the files appear to have been downloaded however when I try to install the application that has been downloaded from the FTP server I get errors indicating that the files have been corrupted.. if I use FtpGetFile API to download the same file sets it all works OK
here is a sample of my function can anyone see why it screws up the files
//Start Code
' This section works
' bret = FtpGetFile(hConnection, szFileRemote, szFileLocal & "/" & szFileRemote, False, _
' INTERNET_FLAG_KEEP_CONNECTION, dwType, 0)
strCommand = "REST 0"
bret = FtpCommand(hConnection, False, FTP_TRANSFER_TYPE_ASCII, strCommand, 0, hFile)
DoEvents
strCommand = "RETR " & szDirRemote & szFileRemote
bret = FtpCommand(hConnection, True, dwType, strCommand, 0, hFile)
DoEvents
Dim bDoLoop As Boolean
Dim sReadBuffer As String * 2048
Dim lNumberOfBytesRead As Long
Dim sBuffer As String
' Open local file for writing
Dim F1 As Integer
F1 = FreeFile
Open szFileLocal & "" & szFileRemote For Binary As F1
bDoLoop = True
While bDoLoop
sReadBuffer = vbNullString
' Read data from data connection
bDoLoop = InternetReadFile(hFile, sReadBuffer, Len(sReadBuffer), _
lNumberOfBytesRead)
' Save received data to local file
Put F1, , sReadBuffer
If Not CBool(lNumberOfBytesRead) Then bDoLoop = False
Wend
' Close local file
Close F1
bret = InternetCloseHandle(hFile) 'if we dont close the handle it will not read the next file
//End Code
DWType is set to Binary (2)
if anyone has any clue please advise
Regards
--------------------------------------------------------------------------------
How Can I Download A Binary File Use 'InternetReadFile' In HTTP
How can i download a binary file use 'InternetReadFile' in HTTP ?
i found it can download txt file only, but i need download a binary file from internet, and cannot use FTP!!
Thann u!
--------------------------------------------------------------------------------
InternetOpenURL(), InternetReadFile() Problem... Download Running Away (wininet Dll)
I have a program that downloads files from the web (automatically) and stores them. I do the downloading with the code below (give to me by someone else on this board!) and it works great... for no reason at all - sometimes the downloads just seem like they don't even try to DL and my program just goes through page after page (kinda like it runs away). Since these are compiled instances I can't see what's wrong... I'm trying to test it in the development environment to see what's up but it's not recreating the problem.
I am on a cable modem and I have multiple instances of the software working... it'll work fine (sometimes hours after starting, and others just minutes after starting) and then the program will just start running away and going through pages it needs to download... acting like they downloaded but they definately didn't.
I know I have give nothing to base a hypothesis of what's wrong on, but I was jsut wondering if anyone knows of an inherit problem with this code, something that the cable modem/ISP could do to trigger this behavior, or something I might be doing wrong that could cause this.
Thanks
VB Code:
'downloading for the 'download' bitOption Explicit Private Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" (ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As String, ByVal sProxyBypass As String, ByVal lFlags As Long) As LongPrivate Declare Function InternetOpenUrl Lib "wininet.dll" Alias "InternetOpenUrlA" (ByVal hInternetSession As Long, ByVal sURL As String, ByVal sHeaders As String, ByVal lHeadersLength As Long, ByVal lFlags As Long, ByVal lContext As Long) As LongPrivate Declare Function InternetReadFile Lib "wininet.dll" (ByVal hFile As Long, ByVal sBuffer As String, ByVal lNumBytesToRead As Long, lNumberOfBytesRead As Long) As IntegerPrivate Declare Function InternetCloseHandle Lib "wininet.dll" (ByVal hInet As Long) As Integer Private Const IF_FROM_CACHE = &H1000000Private Const IF_MAKE_PERSISTENT = &H2000000Private Const IF_NO_CACHE_WRITE = &H4000000 Private Const BUFFER_LEN = 256Dim source As String Public Function GetURLSource(sURL As String)On Error GoTo ErrorHandler Dim sBuffer As String * BUFFER_LEN, iResult As Integer, sData As String Dim hInternet As Long, hSession As Long, lReturn As Long hSession = InternetOpen("vb wininet", 1, vbNullString, vbNullString, 0) If hSession Then hInternet = InternetOpenUrl(hSession, sURL, vbNullString, 0, IF_NO_CACHE_WRITE, 0) If hInternet Then iResult = InternetReadFile(hInternet, sBuffer, BUFFER_LEN, lReturn) sData = sBuffer Do While lReturn <> 0 iResult = InternetReadFile(hInternet, sBuffer, BUFFER_LEN, lReturn) sData = sData + Mid(sBuffer, 1, lReturn) Loop End If iResult = InternetCloseHandle(hInternet) GetURLSource = sData Exit FunctionErrorHandler:'MsgBox "Sub/Function: GetURLSource" & vbCrLf & vbCrLf & "Encountered error #" & Err.Number & vbCrLf & Err.DescriptionResume NextEnd Function
PS: When I unplug my ethernet cable they all 'wait' and stop where they are... then when I plug it back in they resume... this is a great feature but it means that it isn't because the internet connection might be lost or timeout.
--------------------------------------------------------------------------------
File Download Using InternetReadFile Corrupts File Contents
All,
I have an OCX that downloads files from a Server using the following VB code. The application has been developed as an OCX using VB6 SP4 on Windows 2000 SP3. This code works fine on all US and European Locales, however, it does not work well in a Japanese machine running Windows 2000 environment. Text files seem to load ok, however, MS Office documents get corrupted.
Please advise.
Joginder
------------------------------------------------------------------------------------------------------------------------
Dim hFile As Long
Dim Buffer As String * CHUNK_8192
Dim BytesRead As Long
Open Filename For Binary Access Write Lock Read Write As #hFile
Do
Buffer = vbNullString
InternetReadFile hRequest, Buffer, Len(Buffer), BytesRead
If BytesRead > 0 Then
Dim Bytes() As Byte
ReDim Bytes(getByteCount(Buffer)) As Byte
Bytes = StrConv(Buffer, vbFromUnicode)
ReDim Preserve Bytes(BytesRead - 1) As Byte
Put #hFile, , Bytes()
End If
Loop While BytesRead > 0
Close #hFile
--------------------------------------------------------------------------------
RTP Streaming In VB ?
Does any know if RTP streaming can be done (easily) in Visual Basic??
I was wondering if anyone had any sample code, or examples of how to implement RTP in VB, if it can be done at all.
Unfortunately I required a very quick reply, but a yes or no is sufficient as its just for a progress report.
Cheers,
Craig
--------------------------------------------------------------------------------
STREAMING MP3 Possible?
hey all
im want to try and make a server that will play streaming mp3
so if i connect with a client i'll hear a streaming mp3 that is playing on the server. kinda like a radio
anyone think they know how to do it? maybe winsock or something similar?
Thanks for any input
--------------------------------------------------------------------------------
Help With Streaming
ive searched around looking for examples of streaming audio and have come up with this can anyone help me in making it work
--------------------------------------------------------------------------------
Streaming...
can any one give me a start point in streaming audio over the net?
--------------------------------------------------------------------------------
Streaming
How hard/possible would it be (in vb) to take like 20 meg (each) or so clips of various videos or whatever, and then create a client and server program and host the videos on the server and the client program can connect and have it streamed to them.. and as they download - it would play.. so they can watch while the download is staying like 1 minute ahead of their current picture (or more if on faster connection)
Does vb have any good, workable streaming options?
-Sac
--------------------------------------------------------------------------------
MP3 - Streaming Over Net
Hi there,
Concerning my previous message, now I'm asking if someone knew easy way to make a program which streams MP3-files from a HTTP server? Is there already some controls to this kind of use?
- Ville
--------------------------------------------------------------------------------
Streaming MP3 Over A Lan
I need a way to stream MP3 audio over a network.
I just have a problem with sending the data over the network.
Thanks alot
--------------------------------------------------------------------------------
Streaming MP3 Over A Lan
I need a way to stream MP3 audio over a network.
I just have a problem with sending the data over the network.
Thanks alot
--------------------------------------------------------------------------------
Streaming
where can i find the
MS internet audio streaming support?... please beg ya!!!!
--------------------------------------------------------------------------------
Streaming Mp3 In VB 6
Well I have to create a program of my choice for my visual basic class. I decided to create something useful, and wanted to make an mp3 player specifically for my radio station http://radio.maddhat.com. Well, I cant figure out how to approach this.
I have added the windows media player to the form, but I cant get it to play a file correctly...I have been browsing forums for a few days, but cant find a solution. I am running windows xp, could that be a problem? My second question, instead of getting a file on the computer to play, how do I make it play an audio stream? Thanks in advance for your help!
--------------------------------------------------------------------------------
GDI+ Example 6 Streaming Bitmaps
OnErr0r,
I saw your GDI+ example #6 in the code library on streaming bitmaps.
It looks interesting and I would like to find out more about this but having never done anything with streaming before I found myself a bit out of my depth when reading your code.
I tried searching on the internet for more infomation but pretty much everything I found was for C++ or C# and I dont really understand those languages either.
I was wondering if you could perhaps update your example and show in a bit more detail how it could be used.
Could it for example be used to download images from the internet? eg a bitmap.LoadFromURL function? I would like to see the load and send from streams as well that you suggested which might be able to be used with winsock.
I suspect you are a busy man but thought there was no harm in asking.
--------------------------------------------------------------------------------
Video Streaming
I'm looking for some advice, examples or direction on where to find information about playing streaming video in a visual basic application. I can play downloaded video in VB, but streaming is a little different. For what I'm trying to do, I want to avoid using HTML pages for this.
Anyways - I'd appreciate any suggestions and help with this
Thanks!
--------------------------------------------------------------------------------
Streaming Zip Files?
I'm looking for advice on how to get information out of a zip file without having to unzip it. Is this possible with VB?
JJJ
--------------------------------------------------------------------------------
Video Streaming In Vb6
i have created a surveillance system which displays video from a webcam on a vb form. i want to upload this video to the net so that the user can view the video in real time. any ideas how to do this in vb6?
--------------------------------------------------------------------------------
MPEG2 Streaming
ok, ll i want to do is create an mpeg2 stream from a client to a host on a local network(no internet). just like a DVB broadcast.
video data to the host will be from an input device such as a webcam, output on the client will be a simple video box.
i figure i will need encoding/decoding software either side of the network.
anyone know where i could any info on this.
--------------------------------------------------------------------------------
Streaming With DirectShow Help...
I am trying to stream from a tv tunner card to a file... The way Microsoft explains it for VBScript (Link below) I have to:
1. Create two separate instances of the video control, first one is to receive and record (Sink), the second to display(Source).
2. Create a tune request and pass it's stream buffer sink instance of the video control.
3. Add the encoder feature to the active features collection. (Thinking this is where I am messing things up!)
4. Enumerate the available output devices in the GUID_NULL category and set the sink object as the active output device.
5. Specify the file for the output.
6. Disable audio and video rendering in the video control for the stream buffer sink.
7. Enumerate the available input devices in the GUID_NULL category and set the source device as the active input device.
8. Specify the same file as before and run both video control instances.
http://msdn.microsoft.com/library/de...erinscript.asp
Now, I have completed all of the code, as seen below, but I can not get the encoder section to work. I think I have to add the encoder to the available features, but can not figure out how to do so...
Code:
Private Const ENC_CLSID = "{BB530C63-D9DF-4B49-9439-63453962E598}"
Private Const GUID_NULL = "{00000000-0000-0000-0000-000000000000}"
Private Const SINK_CLSID = "{9E77AAC4-35E5-42A1-BDC2-8F3FF399847C}"
Private Const DVR_CLSID = "{AD8E510D-217F-409B-8076-29C5E73B98E8}"
Private Sub cmdStream_Click()
Dim MyFeatures As New MSVidFeatures
Dim Feature As IMSVidFeature
Dim objTuneRequest As IChannelTuneRequest
Dim objTSContainer As New SystemTuningSpaces
Dim objTuneSpace As ITuningSpace
Dim objAnalogTuneSpace As New AnalogTVTuningSpace
'Remove previous instances of the tuning space
For Each objTuneSpace In objTSContainer
If objTuneSpace.UniqueName = "MyTV" Then
objTSContainer.Remove "MyTV"
End If
Next
'Create a new tuning space
objAnalogTuneSpace.CountryCode = 1
objAnalogTuneSpace.UniqueName = "MyTV"
objAnalogTuneSpace.FriendlyName = "My Television"
objAnalogTuneSpace.MaxChannel = 69
objAnalogTuneSpace.MinChannel = 1
objAnalogTuneSpace.NetworkType = "{00000000-0000-0000-0000-000000000000}"
objAnalogTuneSpace.InputType = TunerInputCable
Set objTuneSpace = objAnalogTuneSpace
objTSContainer.Add objAnalogTuneSpace
'Set the new tuning space in the sink video control
Set objTuneRequest = objTSContainer("MyTV").CreateTuneRequest
objTuneRequest.Channel = intChannel
MSVidCtl_Sink.View objTuneRequest
'Get the available features for the control, which won't get the encoder?
For Each Feature In MSVidCtl_Sink.FeaturesAvailable
If (Feature.ClassID = ENC_CLSID) Then
MyFeatures.Add Feature
End If
Next
'Set the encoder for the control
MSVidCtl_Sink.FeaturesActive = MyFeatures
Dim objStreamBufferSink As MSVidStreamBufferSink
Dim output As IMSVidOutputDevice
Dim MyOutputs As MSVidOutputDevices
Set MyOutputs = New MSVidOutputDevices
'Set the output for the sink control, works fine...
For Each output In MSVidCtl_Sink.OutputsAvailable(GUID_NULL)
If output.ClassID = SINK_CLSID Then
MyOutputs.Add output
Set objStreamBufferSink = output
End If
Next
'Set the output
Set output = objStreamBufferSink
MSVidCtl_Sink.OutputsActive = MyOutputs
'Set the file
objStreamBufferSink.SinkName = "c:sample.wmv"
'Disable the audio and video rendering
MSVidCtl_Sink.DisableVideo
MSVidCtl_Sink.DisableAudio
Dim objStreamBufferSource As MSVidStreamBufferSource
Dim inputt As IMSVidInputDevice
'Get the available inputs from the source control
For Each inputt In MSVidCtl_Src.InputsAvailable(GUID_NULL)
If inputt.ClassID = DVR_CLSID Then
MSVidCtl_Src.InputActive = inputt
Set objStreamBufferSource = inputt
End If
Next
'Retreive the file
objStreamBufferSource.FileName = "c:sample.wmv"
'Run both controls
MSVidCtl_Src.Run
MSVidCtl_Sink.Run
End Sub
I removed the error handleing for simplicity, but the sink and source were found and set correctly. The encoder CLSID was not found or set and I think this is where my trouble is at... Any ideas???
--------------------------------------------------------------------------------
Sound Streaming
How would i go about streaming sound from one computer to another using winsock any links or tips would be nice
--------------------------------------------------------------------------------
Streaming Audio
I would like to know how i could add streaming audio (WMA i think) + controls to my program. It would have to play mms://stream04.pandora.be/stubrusmal
when clicking on play button, pause when clicking pause button,...
Please keep it as simple as possible and be complete since i kinda only know the basics of Visual Basic (using visual Basics 6.0)
--------------------------------------------------------------------------------
RealTime Streaming
Hai guys,
I want to create a real time video streaming client and server. Can anybody tell me where I could find any articles, resources to do this work in VisualBasic. I could not find a suitable article by searching in Google.
If any of you guys find anything regarding this please let me know. I prefer any article written specifically for VB or Java(If there is no dot net stuff)
--------------------------------------------------------------------------------
Streaming Data
Can anyone help... I am trying to save streaming stock quote data from a web page as CSV, and am using excel and VBA??
--------------------------------------------------------------------------------
Streaming MP3 Data
Is there a way to give DirectShow or MCI pure MP3 data and have it play it? I've been working on a ShoutCast player, and the only way I've been able to do it is with a double-buffer file system by saving the data in chunks and playing one chunk while downloading another (3 chunks total, one playing, one waiting to be played, one downloading). This causes some annoying pauses in between chunks. I need a better way to play the data than that.
--------------------------------------------------------------------------------
Msdxm, Wmp.dll And Streaming
I have a linux server streaming mp3s via gnump3d
With windows mediaplayer (msdxm.ocx) when I tgry to play the file it downloads it full before it plays it. With wmp.dll it plays it as soon as there is enough of the file in the buffer. Since the wmp.dll end of stream funciton is disabled I find that the wmp.dll hard to use in my particular application and would rather use msdxm.ocx Can anybody suggets why the older ocx cannot play a file until it is full downloaded but the newer windows media player can?
Thanks
--------------------------------------------------------------------------------
Streaming Audio
Hi guys,
I'm looking for a library of some sort that does one of these things:
1) Connects to a streaming audio source and pipes it through to a waveout device specifiable in code.
2) Connects to a streaming audio source and passes back the audio buffers to my code so I can pass it on to a waveout device.
It would need to be able to connect to WM, Real and ShoutCast streams. All in one component would be nice but separates is doable too.
It wouldn't have to be free, this is a commercial project. All the stuff I've managed to google has been complete and utter crap.
Any ideas?
--------------------------------------------------------------------------------
Streaming Webcam
hey,
i've seen many webcam projects but there all image-based. but when i see a program like msn messenger the webcam is pretty streaming.
HOW?
--------------------------------------------------------------------------------
Streaming Array
I have a streaming array that has 2 demensions. One of the dimensions acts as an index. The second dimension is an integer that I would like to track. I want to create a second array that aggregates all of the values that are in the first array 2nd dimension. Any ideas>
MJ
--------------------------------------------------------------------------------
Video Streaming
hi, i know this might sounds like it should be in the communications forum but i know how to send information. the part im stuck on is how do i take a picture from a picture box and convert it to something that can be streamed. then when it gets to the other side, how can i make it display it in a browser window?
--------------------------------------------------------------------------------
Sound Streaming
How would i go about streaming sound from one computer to another using winsock any links or tips would be nice
Im trying to make something like the talk feature in AIM.
--------------------------------------------------------------------------------
Streaming Audio In VB?
I would like to make my own voice server (like teamspeak, ventrillo, etc) in visual basic.
I have searched all over and found nothing but windows media encoder sdk, which I couldn't get to work.
Anyone know of any code I can look at or controls that would simplfy this task? I actually have no clue how to go about doing this. I'm using Visual Basic 6.0.
I don't want to have to figure out how to write and send a .wav file while its open and delete what has already been sent or something.. I'm looking for something like a control or set of controls that would automate most of the process. Maybe a control for recording from mic to , then a control that sends from to an IP address... I don't know.
Any help on this topic would be appreciated.
--------------------------------------------------------------------------------
Streaming Data
HELLO!
I want to use a VB 6.0 to receive streaming data from server side, like streaming stock quotes on Bloomberg.
Anyone know how to do this? Any example?
THANK YOU
--------------------------------------------------------------------------------
Streaming Video
Hi, does anybody know how to play an online video stream when I have an url like this: http://111.22.1.222:5555 ?
I can play the online stream with VideoLAN player by using the Network Stream option, but I'd like to play the online stream in a VB app.
A bandwidth meter shows it does stream the video, but for some reason WMP only shows "connecting to media..." but won't actually play it. Probably because it's a camera that runs 24/7 and not a video from a website you can download/buffer.
VB Code:
Private Sub Form_Load()WindowsMediaPlayer1.URL = "http://111.22.1.222:5555"WindowsMediaPlayer1.Controls.playEnd Sub
--------------------------------------------------------------------------------
Data Streaming
Hi there Guys,
I'm learning VB6. I have a problem I can't get my mind around which is related to this thread.
I have data streaming in - FX quotes. I need to write these to a file so that my charting program can read them. I have two Types, the first is a header file. the second is the data set as various variable lengths. the two types have different file lengths. As the output file is updated so the charting program will read the new data and chart it to a graph
I have tried, put,get seek etc.but cannot append to the file without destroying the file header. I have been working with Open in either random or binary modes. All I want to do is to place the new data at the end of the file and retain the file to append future updates and also for historical purposes. The file is updated at two second intervals. So that as the file gets bigger, the logistics of calculating the filelength and seeking EOF become an ipediment to the accuracy of the file input.
Any comments as to procedure wuold be welcome. Regards to you all