Click here to Skip to main content
15,894,646 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: VB Operating System Pin
Paul Conrad25-Oct-11 5:48
professionalPaul Conrad25-Oct-11 5:48 
AnswerRe: VB Operating System Pin
Richard Andrew x6425-Oct-11 5:49
professionalRichard Andrew x6425-Oct-11 5:49 
AnswerRe: VB Operating System PinPopular
Richard MacCutchan25-Oct-11 6:05
mveRichard MacCutchan25-Oct-11 6:05 
AnswerRe: VB Operating System Pin
Smithers-Jones26-Oct-11 12:11
Smithers-Jones26-Oct-11 12:11 
GeneralRe: VB Operating System Pin
VOT Productions3-Nov-11 12:01
VOT Productions3-Nov-11 12:01 
AnswerRe: VB Operating System Pin
biop.codeproject13-Nov-11 17:08
biop.codeproject13-Nov-11 17:08 
QuestionTCP Socket client communication without using a buffer Pin
comiteco24-Oct-11 12:33
comiteco24-Oct-11 12:33 
AnswerRe: TCP Socket client communication without using a buffer Pin
Eddy Vluggen25-Oct-11 7:19
professionalEddy Vluggen25-Oct-11 7:19 
comiteco wrote:
Please read my code below

There's a comparable example on MSDN[^]. It shows how to receive a variable-length message, which could be a single byte.

comiteco wrote:
You can figure that if I define a buffer of 4000 bytes, I read just 4000 bytes of data sent by the device, but the device keep sending data all the time and I need to keep reading data all the time too, not just 4000 bytes...

You don't have to wait until the buffer is full, in order to use it. From the page on MSDN that I just linked to;
MSDN wrote:
This method reads data into the buffer parameter and returns the number of bytes successfully read. If no data is available for reading, the Read method returns 0. The Read operation reads as much data as is available, up to the number of bytes specified by the size parameter. If the remote host shuts down the connection, and all available data has been received, the Read method completes immediately and return zero bytes.

That means that it receives a complete block at once, and it doesn't wait until the buffer is full. It grabs what's there, and it moves on (doesn't arrive a byte at a time, so you'll need to grab multiple). The buffer won't be completely filled, and you have to make sure to get the entire message - how that's done is shown in the example.
Bastard Programmer from Hell Suspicious | :suss:

QuestionSyntax Error (missing Operator) in query expression '07/08/2011 12:00:00 PM'. Pin
Amanjot23-Oct-11 15:17
Amanjot23-Oct-11 15:17 
AnswerRe: Syntax Error (missing Operator) in query expression '07/08/2011 12:00:00 PM'. Pin
AspDotNetDev23-Oct-11 15:34
protectorAspDotNetDev23-Oct-11 15:34 
GeneralRe: Syntax Error (missing Operator) in query expression '07/08/2011 12:00:00 PM'. Pin
Amanjot23-Oct-11 16:03
Amanjot23-Oct-11 16:03 
GeneralRe: Syntax Error (missing Operator) in query expression '07/08/2011 12:00:00 PM'. Pin
AspDotNetDev23-Oct-11 16:10
protectorAspDotNetDev23-Oct-11 16:10 
GeneralRe: Syntax Error (missing Operator) in query expression '07/08/2011 12:00:00 PM'. Pin
Amanjot25-Oct-11 16:45
Amanjot25-Oct-11 16:45 
AnswerRe: Syntax Error (missing Operator) in query expression '07/08/2011 12:00:00 PM'. Pin
AspDotNetDev25-Oct-11 17:02
protectorAspDotNetDev25-Oct-11 17:02 
GeneralRe: Syntax Error (missing Operator) in query expression '07/08/2011 12:00:00 PM'. Pin
Amanjot30-Oct-11 6:05
Amanjot30-Oct-11 6:05 
GeneralRe: Syntax Error (missing Operator) in query expression '07/08/2011 12:00:00 PM'. Pin
AspDotNetDev30-Oct-11 8:43
protectorAspDotNetDev30-Oct-11 8:43 
GeneralRe: Syntax Error (missing Operator) in query expression '07/08/2011 12:00:00 PM'. Pin
Amanjot31-Oct-11 9:53
Amanjot31-Oct-11 9:53 
GeneralRe: Syntax Error (missing Operator) in query expression '07/08/2011 12:00:00 PM'. Pin
AspDotNetDev31-Oct-11 19:21
protectorAspDotNetDev31-Oct-11 19:21 
GeneralRe: Syntax Error (missing Operator) in query expression '07/08/2011 12:00:00 PM'. Pin
Hypermommy7-Nov-11 9:28
Hypermommy7-Nov-11 9:28 
AnswerRe: Syntax Error (missing Operator) in query expression '07/08/2011 12:00:00 PM'. Pin
AspDotNetDev7-Nov-11 9:38
protectorAspDotNetDev7-Nov-11 9:38 
GeneralRe: Syntax Error (missing Operator) in query expression '07/08/2011 12:00:00 PM'. Pin
Hypermommy7-Nov-11 10:01
Hypermommy7-Nov-11 10:01 
GeneralRe: Syntax Error (missing Operator) in query expression '07/08/2011 12:00:00 PM'. Pin
Hypermommy7-Nov-11 10:16
Hypermommy7-Nov-11 10:16 
GeneralRe: Syntax Error (missing Operator) in query expression '07/08/2011 12:00:00 PM'. Pin
AspDotNetDev7-Nov-11 10:43
protectorAspDotNetDev7-Nov-11 10:43 
GeneralRe: Syntax Error (missing Operator) in query expression '07/08/2011 12:00:00 PM'. Pin
Hypermommy8-Nov-11 3:44
Hypermommy8-Nov-11 3:44 
GeneralRe: Syntax Error (missing Operator) in query expression '07/08/2011 12:00:00 PM'. Pin
AspDotNetDev23-Oct-11 15:37
protectorAspDotNetDev23-Oct-11 15:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.