Sockets - Receiving A Large Buffer?

Apr 22, 2009

(First time trying to do socket programming ) I'm trying to read a large buffer using sockets. Is there anything wrong with this psudo code?

DO
mySocket.Receive(buff) ' temporary buffer, discard the data
WHILE (mySocket.Available > 0)

it terminates after the first iteration because, I suppose, it reads the data faster than the sender is sending it, and Socket.Available will be 0 (if i break the debugger and step through it, it receives the whole buffer). How can i make the Receive call block until more data is available? (I've tried setting Socket.ReceiveTimeout, but it doesn't seem to do any good)

View 3 Replies


ADVERTISEMENT

C# - Can't Exit A Loop With Multiple Buffer Transfer Over TCP / Sockets .net

Oct 26, 2011

I'm transfering data over TCP/Sockets with the .Net (System.Net.Sockets) I am using this code on client side :

[Code]....

View 1 Replies

How To Dynamically Allocate Buffer For Receiving UDP Socket

Feb 20, 2010

A friend and I are working on a project where we're required to build a reliable UDPclient/server using VB.Net. We have things working well, but one thing that still eludes us is how to dynamically allocate a (byte) buffer for the incoming data. Right now we have to hard code a maximum value/MTU (or use a really large buffer size and resize it once we've finished receiving). Does anyone know of a way that this can be done without needing to specify the receive buffer size?

Basically, before calling the receive function on the socket with a buffer of size x, we want to know x so we can allocate an appropriately sized buffer. Perhaps this is a problem in all socket programing that you just have to deal with??

View 1 Replies

Not Receiving All Packets - VB Sockets - Async?

Oct 27, 2009

Here's the code on the sending side of my sockets:

Private Sub Send(ByRef Buffer() As Byte)
Dim obj_StateObject As New StateObject
obj_StateObject.WorkSocket = m_tmpSocket

[code].....

View 1 Replies

2005 - Discard The Contents Of A System.Net.Sockets.Socket Send Buffer Using TheSocket.IOControl(IOControlCode.Flush

Jun 10, 2012

I'm attempting to discard the contents of a System.Net.Sockets.Socket send buffer using theSocket.IOControl(IOControlCode.Flush, .... Does anybody know whether VB.NET supports this command? I've tried supplying 'Nothing' and 'Nothing' for both required parameters, also empty and populated byte arrays in combination with 'Nothing' for both required parameters, but I consistently get an 'Invalid argument' exception. I've tried a web search for an answer, but the only mention I've found was a question asked about 8 years ago, with still no answer.

View 1 Replies

Reading Large File Stream In .net (How Can I Increase Buffer Size)?

Mar 3, 2009

i need to read a large file stream binary my code is Dim sr As New IO.FileStream(srcFile,

[Code]..

View 10 Replies

C# - OutputDataReceived (and ErrorDataReceived) Has A Slow Firing Rate And Creates A Large Buffer?

Nov 5, 2010

is there a way to increase the rate a Process object in .NET throws the OutputDataReceived event? It creates a large buffer (I believe 1024 characters) that is dumped in bulk which makes the application not as fluid of a stream as I would of like it to be.

View 1 Replies

Buffer Cannot Be Null - Parameter Name: Buffer

Dec 15, 2011

[Code]...

This is my code for retrieving pictures, it was working before but then i accidentally deleted the table and i created it again with the same name and same fields. and now whenever i open the form with the picture, there was a message box error. it says Buffer cannot be null. Parameter name: buffer I don't know what i did wrong.

View 5 Replies

Large Multidimensial Array - Write A Program To Do Markov Chain But States Are Quite Large

Jun 9, 2011

I want to write a program to do Markov chain, but my states are quite large. First of all I calculate all the transition probabilities and revenues for all states(1381860 total states), and store in a multidimensional array. Public RevArr(0 To 9, 0 To 750, 0 To 282) As Long

After that the iteration of markov chain should use these as inputs to calculate the steady-state probabilities. But when I try to run the main code I got this error.Exception of type 'System.OutOfMemoryException' was thrown.

The following is the declaration of second array I add just another dimension for storing all the iterations, but I get this error. Dim stateprob(IT + 1, 0 To 9, 0 To 750, 0 To 282) As single

View 1 Replies

Double Buffer Or Not To Double Buffer?

Apr 17, 2010

To Double Buffer or not to Double Buffer this is the Question!I have a form with Protected Overrides Sub OnPaint that sets forms background to a gradient fill ,on top of that is a transparent richtext box.
Ok. now here`s the problem ,If i enable forms double buffering the transparent Rtb doesn't flicker when forms resized. but the forms drop shadow does flicker! ,its a boarderless form using CS_DROPSHADOW to draw the drop shadow Now if i disable double buffering the forms drop shadow doesn`t flicker but the transparent Rtb does ,any one have a clue how to get both to work in harmony !

View 3 Replies

ASCII To HEX Buffer Converting?

Sep 16, 2009

The reply buffer is in ASCII value...but I need is HEX value.Is there any way that the reply buffer is in hex?

Code:
Public Function read_write_string(ByVal devicehandle, ByVal command, ByVal commandlenght) As String
Dim inputReportBuffer(100) As Byte
unManagedBuffer = Marshal.AllocHGlobal(inputReportBuffer.Length)

[code]....

View 4 Replies

Buffer 28 Bytes From The Com Port?

Apr 21, 2010

I have a problem that i cant solve i am trying to buffer 28 bytes from the com port into the array actual_packet_VPS1(30). It works with the counter set to 0 - 15 but doesnt work when we increase the counter size to 0 -28.

Private Sub MSComm5_OnComm(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MSComm5.OnComm
Dim buffer As Object

[Code].....

View 2 Replies

How To Double Buffer A Flowlayoutpanel

Jan 12, 2012

I have a need to double buffer a flowlayoutpanel. I have the form set to doublebuffered which is half the story but their is no property in the list to make the flowlayoutpanel do this (although MSDN states that it has this property) how i can set it to true for the panel?

View 5 Replies

Playing Video From Buffer?

Apr 29, 2012

Im trying to do a video player but i have to play this video from the buffer, is this possible.. Let me explain you much more complicated,a got a CryptoStream and im decryting the video

While lngBytesProcessed < lngFileLength
'Read file with the input filestream.
intBytesInCurrentBlock = fsInput.Read(bytBuffer, 0, 4096)
'Write output file with the cryptostream.

[code]....

This code writes my decryted or crypted video to a new file. However, i need to play the video file from the buffer(without copying to a new file), in other way it would be meaningless if i create a decryted file. in other words it would unsecure for me cuz if anyone can locate my temp directorey they can copy my decrypted video files.

View 5 Replies

Process The Buffer - EOF Expected

Jul 9, 2011

Dim Fs as FileSystemObject
Dim TS as TextStream
Set Fs = CreateObject("Scripting.FileSystemObject")
Set Ts = fs.OpenTextFile(textFilePath, ForReading, False,
TristateUseDefault)
While not Ts.AtEndOfStream
Buffer=Ts.ReadLine
' Process the buffer
Wend
Ts.Close
Fs.Close
I tried to convert into c# but am getting ERROR like EOF expected, what I have to do?

View 3 Replies

Streaming To A Buffer And Then Using Data?

Jul 31, 2010

I am using VB.net sockets to send a music file from one instance to another. It currently saves the file, but I do not want to be caught up in file-sharing, so I want to "save" it to a buffer, and when it gets to a particular percentage transferred, I want another thread to play the music file, deleting it from the buffer as it plays. I have the code to send it over the network, but I need to know how to keep it in a buffer and not save it as a file.

View 1 Replies

VB To .net Conversion Buffer String?

Sep 3, 2011

I've looked and looked + tryed debugging but I'm not getting anywhere fast I'm trying to import a usb radio driver and I'm 99% there. I can turn it on / off and get / set the freq.. but I'm struggling to get the rds name from it. The VB code for the function is

[Code]...

View 7 Replies

.net - High Speed Circular Buffer?

Jun 8, 2012

I have been asked to improve the memory efficiency of an application that is used for high speed data acquisition. After running the VS memory profiler several times and scanning the projects for obvious issues I came to the following conclusion: despite using a fixed size circular buffer for storing acquired sample points, the RAM usage increases relative to the polling period. For example: polling data for one signal at 2 microseconds can use 5 times more memory (private bytes) than when running at 50 microseconds ... even though the buffer size is the same.

The circular buffer is an array of SamplePoint objects. Each of these objects contains an array of Shorts (16 bit) for corresponding data per signal and one date object (8 bytes) for the time stamp. For efficiency, the circular buffer is Redimmed only once every time it begins polling and filled with empty sample points which are then "assigned".

Also, it seems that when we stop and run the application it hogs even more memory each time as though the Redim is not releasing the previous array. My questions boil down to the following: What is most memory efficient way of implementing a circular buffer containing managed objects which have arrays?Also, how and why is memory usage increasing with a fixed size array with different polling speeds? Does the garbage collector not have time? Do local variables get disposed of IMMEDIATELY when a sub or function exits?These are some of the doubts and concerns that I would like to rule out before proceeding.

[Code]...

View 1 Replies

.net - Make A Packet Using Dim Buffer As Byte()?

Mar 7, 2012

basically I'm sending and receiving both images, strings and files over a client/server connection. I can easily use a protocol for string commands but I cannot distinguish between the incoming data [if data is image or whatever and then follow onward instructions].So how do I make a packet using Dim buffer as byte()?

View 2 Replies

Create A Circular Buffer On The Heap?

Feb 24, 2010

How can I create a circular buffer on the heap in VB.NET ? This would be used for audio playback via P/Invoke to winmm.dll waveoutopen and waveoutwrite to support development of a software synth. I currently use the marshall class to build a regular array of bytes in the heap.

View 1 Replies

Get Double Buffer Function Working

Dec 13, 2011

I've been trying to get the double buffer function working in VB.NET GDI+ for a space invaders game using the following command.[code]But because I am using a separate draw routine attached to a class it doesn't seem to work:[code]The aliens draw correctly but the images are very stuttery and double buffering doesn't seem to work.

View 1 Replies

How To Find Socket Buffer Size

Jan 4, 2009

I have connected to a host, but how do I find the correct buffer size? (The Buffer is currently set to 8k (8192))
Dim webget As New Net.Sockets.Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
webget.Connect(host, port)
webget.Send(data, 0, data.Length, SocketFlags.None)
Dim rData(8192) As Byte
webget.Receive(rData, rData.Length, 0)

View 14 Replies

Maximum Buffer Length Is Exceeded?

Jul 26, 2011

I see this error page appears in some client access but some client didn't see this.

View 2 Replies

Reading Ports To A Buffer To Parse

Nov 15, 2009

I'm currently working on a little software for my GPS and i havent touched VB in about 10 years so I'm trying to figure this out from scratch again pretty much. Anyway, I have this code to get the information from the GPS and parse it, the only problem is that It isn't getting all the code at once and then parsing, it is getting bits and pieces and only getting the RIGHT code from time to time..

Private Sub timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles timer1.Tick

[Code]....

View 6 Replies

Search A String Buffer With Nulls (chr(0))?

Sep 25, 2009

I need to search a buffer for a string of characters.The buffer is essentially a binary file (it's an image) and contains lots of chr(0) characters.The string I need to locate also contains chr(0) characters. In fact it is the following string:

chr(100) & chr(0) & chr(0) & chr(163)

This is a marker in the image file for items I need to process.So I though I would do the following:

Dim sFileBuffer as String = system.io.file.readalltext("myimagefile")
Dim sLookFor as String = chr(100) & chr(0) & chr(0) & chr(163)
Dim iLocation as Integer = sFileBuffer.IndexOf(sLookFor)

The problem is that, although the characters in sLookFor definitely exist inside of sFileBuffer - IndexOf will always return -1 (not found).I tried the following:

Dim Marker() as Byte = {100, 0, 0 , 163}
Dim sLookFor as String = System.Text.Encoding.UTF8.GetString(Marker)
Dim sFileBuffer as String = system.io.file.readalltext("myimagefile", Encoding.UTF8)
Dim iLocation as Integer = sFileBuffer.IndexOf(sLookFor)

But this appears to only find occurrences of Chr(100) & Chr(0) - not the full 4 character sequence I desire. It appears to see the second Chr(0) as a termination of the search string.I think the sticking point here is the null. Yes - I can string.replace(chr(0), Chr(255)) in both the sLookFor and the sFileBuffer and adjust my search accordingly - but that seems like a mess to me.Is there not a way to search a buffer of binary data? I've tried working with byte arrays - but there appears to be no way to easily search for a sequence of byte values - just individual elements in the array.

View 11 Replies

SerialPort DataReceived Buffer Construction?

Jun 15, 2011

I've managed to make an application at home using a serialport emulator and connector that will read text from a file on my desktop send it to com1 and then my connector program will merge com1 with com2. In short my program works at home but when I connect it to my device it appears the data in DataReceived is a fraction of what my simulator setup at home is producing, which apparently is completely normal according to all these threads I've read here.

[Code]...

View 4 Replies

Setting A TextBox Buffer Size?

Jan 20, 2009

How can a TextBox or RichTextBox buffer size be set? I have data that goes to a TextBox continuously, but I want to set a maximum size of buffer for the TextBox. I read in one forum someone suggesting to set the TextBox MaxLength property, but the questioner replied that he had tried this, and when the MaxLength was reached no further data input was possible, and what he wanted was the situation where new data could still come in, but the oldest data was then deleted, i.e a rolling buffer, which is precisely

View 3 Replies

Setting StreamWriter Buffer Size

Jan 26, 2012

I built a console application that reads a directory of files, builds a 'put' statement for each file and submits each statement to a webservice. Then, it reads the webservice output (for each statement), parses it for a specific string, builds a 'get'statement and submits the 'get' to the webservice (for each file).Then, the application reads the 'get' output stream and writes a file (to the local file system) for each file that was submitted, using a streamwriter.I have encountered an issue where some files are unable to be written to the local file system by the streamwriter.After much testing I have figured out that any file exceeding 4096 bytes will cause the application to hang where streamwriter should write the output to file.I have tried the syntax below to increase the size of the streamwriter buffer however, it doesn't seem to be working.I do need to mention that I am an extreme novice with VB or any other language and have, for the most part written this module from research and code samples.I should mention that this module does work for any file that is less than 4096 bytes in size.

View 6 Replies

Thermometer Serial Port Buffer ?

Jun 7, 2011

I am trying to communicate with an Extech 421509 Thermometer via the serial port.Since I do not know VB very well I first wrote the program in LabVIEW to make sure I knew how to write the program, once I was successful with that I tried to write the code in VB.I am mostly successful with that except that in VB my buffer will be read 4 or 5 times and then there is nothing on my buffer. In LabVIEW I do not have this problem as I write to the buffer I can immediately read from the buffer.

Imports System
Imports System.IO.Ports
Imports System.Threading[code]....

View 1 Replies

VS 2008 - ASCII To HEX Buffer Converting

Sep 16, 2009

I found this function from the net. But I have a problem with the reply buffer. The reply buffer is in ASCII value...but I need is HEX value. Is there any way that the reply buffer is in hex?

[Code]...

View 7 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved