Click here to Skip to main content
15,915,093 members
Home / Discussions / C#
   

C#

 
JokeRe: Entity Frame work Pin
Richard Deeming14-May-13 3:59
mveRichard Deeming14-May-13 3:59 
GeneralRe: Entity Frame work Pin
Pete O'Hanlon14-May-13 4:01
mvePete O'Hanlon14-May-13 4:01 
GeneralRe: Entity Frame work Pin
Dave Kreskowiak14-May-13 3:59
mveDave Kreskowiak14-May-13 3:59 
GeneralRe: Entity Frame work Pin
TnTinMn14-May-13 11:12
TnTinMn14-May-13 11:12 
GeneralRe: Entity Frame work Pin
AspDotNetDev14-May-13 11:16
protectorAspDotNetDev14-May-13 11:16 
AnswerRe: Entity Frame work Pin
Dave Kreskowiak14-May-13 3:46
mveDave Kreskowiak14-May-13 3:46 
QuestionHow would you clear a tcp buffer or detect if there is data there ? Pin
Member 986287213-May-13 21:40
Member 986287213-May-13 21:40 
AnswerRe: How would you clear a tcp buffer or detect if there is data there ? Pin
SoMad13-May-13 22:43
professionalSoMad13-May-13 22:43 
This is probably not how I would do it, but if things are as simple as you describe and you don't think it will change in the future, you should be able to make it work.
Your code is basically very similar to the sample code in this MSDN article: http://msdn.microsoft.com/en-us/library/system.net.sockets.socket(v=vs.100).aspx[^].
Notice in SocketSendReceive() how they do the Receive() in a while loop, adding to the final string each time through the loop (if you follow that sample, you might want to use a StringBuilder object instead of just adding onto the string).

I suspect your truncated and left over data issues are due to the fact that you just try to read the data into your fixed size buffer in a single Receive() call. If you don't want to use a while loop in the reading part, you could use the socket objects Available property[^] to see how much data has been received and set the size of your buffer accordingly. It is not something I will recommend because you might have to change the sockets ReceiveBufferSize to be able to receive the largest data block the device can send to you - that can end up being a frustrating back and forth exercise.

Soren Madsen
"When you don't know what you're doing it's best to do it quickly" - Jase #DuckDynasty

GeneralRe: How would you clear a tcp buffer or detect if there is data there ? Pin
Member 986287215-May-13 4:30
Member 986287215-May-13 4:30 
AnswerRe: How would you clear a tcp buffer or detect if there is data there ? Pin
Richard MacCutchan13-May-13 22:45
mveRichard MacCutchan13-May-13 22:45 
AnswerRe: How would you clear a tcp buffer or detect if there is data there ? Pin
jschell14-May-13 9:28
jschell14-May-13 9:28 
Questionruntime error Pin
n.nili13-May-13 19:04
n.nili13-May-13 19:04 
AnswerRe: runtime error Pin
Pete O'Hanlon13-May-13 21:22
mvePete O'Hanlon13-May-13 21:22 
AnswerRe: runtime error Pin
dusty_dex13-May-13 22:20
dusty_dex13-May-13 22:20 
Questionstring concatenation with all possibilities Pin
sethupathiram13-May-13 3:19
sethupathiram13-May-13 3:19 
AnswerRe: string concatenation with all possibilities Pin
Pete O'Hanlon13-May-13 3:30
mvePete O'Hanlon13-May-13 3:30 
AnswerRe: string concatenation with all possibilities Pin
Simon_Whale13-May-13 3:38
Simon_Whale13-May-13 3:38 
AnswerRe: string concatenation with all possibilities Pin
PIEBALDconsult13-May-13 4:33
mvePIEBALDconsult13-May-13 4:33 
AnswerRe: string concatenation with all possibilities Pin
Richard Deeming13-May-13 5:06
mveRichard Deeming13-May-13 5:06 
AnswerRe: string concatenation with all possibilities Pin
Anna King14-May-13 2:56
professionalAnna King14-May-13 2:56 
QuestionError 1 The type or namespace name 'Form1' Pin
Topias Jäppilä13-May-13 2:06
Topias Jäppilä13-May-13 2:06 
QuestionRe: Error 1 The type or namespace name 'Form1' Pin
Richard MacCutchan13-May-13 2:39
mveRichard MacCutchan13-May-13 2:39 
AnswerRe: Error 1 The type or namespace name 'Form1' Pin
Topias Jäppilä13-May-13 4:44
Topias Jäppilä13-May-13 4:44 
GeneralRe: Error 1 The type or namespace name 'Form1' Pin
Richard MacCutchan13-May-13 5:02
mveRichard MacCutchan13-May-13 5:02 
GeneralRe: Error 1 The type or namespace name 'Form1' Pin
Topias Jäppilä13-May-13 5:08
Topias Jäppilä13-May-13 5:08 

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.