Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - I can WRITE thru Ethernet but can't READ from it???

Reply
 
Old 05-27-2009   #1 (permalink)
Alan Mailer


 
 

I can WRITE thru Ethernet but can't READ from it???

Please help me not tear out the last of my hair....

I've succeeded with the code below to *WRITE* messages over LAN
Ethernet to a receiving device that accepts my transmitted data and
internally does what the data I'm sending it commands it to do:

**********************************************************************************
MyTcpClient = New System.Net.Sockets.TcpClient
MyTcpClient.Connect(txtIPAddr.Text.ToString, CInt(txtIPPort.Text))
Dim nsNetstream As NetworkStream = MyTcpClient.GetStream()
MyNetworkStream = nsNetstream
Dim bytOutgoingData As Byte() = _
clsMyStringTranslator.HexBecomesByte("MyCommandToTheDevice")
MyNetworkStream.Write(bytOutgoingData, 0, bytOutgoingData.Length)
*********************************************************************************

....Now. please understand that the device I'm talking to automatically
sends out feedback after it has received a command. That having been
said... I CAN'T SEEM TO COME UP WITH A SUCESSFUL WAY OF RECIEVING THE
FEEDBACK!*

I'm hoping someone reading this will take a moment or two to *spell
out* how I would go about this. I'm emphasizing 'spell out' because
I'm feeling like I need a fully-fledged example. I've tried searching
the web and attempted playing for several hours with TCPListeners,
Sockets, etc... but this stuff is relatively new to me and I must be
doing something wrong; even if I have been playing in the correct
territory.

For what it's worth, I need to come up with some sort of 'read
incoming Ethernet data' routine that will NOT hang up my application;
which, if I'm understanding this, means I may need to perform this
asynchronously. (Although, if this is relevant, the device I'm
talking to always sends it's feedback immediately after it receives a
command).

A few things you should know: As I say, WRITING to this device has
not been a problem. Further, I have verified through other means
(Comm port communication for example) that the device IS sending
feedback. So the problem lies with me, not the device.

Can anyone offer a fairly complete example of how I should go about
this? PLEASE!

Thanks in advance.

My System SpecsSystem Spec
Old 05-29-2009   #2 (permalink)
John Vottero


 
 

Re: I can WRITE thru Ethernet but can't READ from it???

"Alan Mailer" <clarityassoc@xxxxxx> wrote in message
news:bkur1553v4l4duuk37tsn97uhp0jc3a9ge@xxxxxx
Quote:

> Please help me not tear out the last of my hair....
>
> I've succeeded with the code below to *WRITE* messages over LAN
> Ethernet to a receiving device that accepts my transmitted data and
> internally does what the data I'm sending it commands it to do:
>
> **********************************************************************************
> MyTcpClient = New System.Net.Sockets.TcpClient
> MyTcpClient.Connect(txtIPAddr.Text.ToString, CInt(txtIPPort.Text))
> Dim nsNetstream As NetworkStream = MyTcpClient.GetStream()
> MyNetworkStream = nsNetstream
> Dim bytOutgoingData As Byte() = _
> clsMyStringTranslator.HexBecomesByte("MyCommandToTheDevice")
> MyNetworkStream.Write(bytOutgoingData, 0, bytOutgoingData.Length)
> *********************************************************************************
>
> ...Now. please understand that the device I'm talking to automatically
> sends out feedback after it has received a command. That having been
> said... I CAN'T SEEM TO COME UP WITH A SUCESSFUL WAY OF RECIEVING THE
> FEEDBACK!*
>
> I'm hoping someone reading this will take a moment or two to *spell
> out* how I would go about this. I'm emphasizing 'spell out' because
> I'm feeling like I need a fully-fledged example. I've tried searching
> the web and attempted playing for several hours with TCPListeners,
> Sockets, etc... but this stuff is relatively new to me and I must be
> doing something wrong; even if I have been playing in the correct
> territory.
Sounds like you're making this too hard. You don't need a TCPListener or
another socket, just do:

MyNetworkStream.Read(...) or MyNetworkStream.BeginRead(...) to start an
async read.
Quote:

>
> For what it's worth, I need to come up with some sort of 'read
> incoming Ethernet data' routine that will NOT hang up my application;
> which, if I'm understanding this, means I may need to perform this
> asynchronously. (Although, if this is relevant, the device I'm
> talking to always sends it's feedback immediately after it receives a
> command).
>
> A few things you should know: As I say, WRITING to this device has
> not been a problem. Further, I have verified through other means
> (Comm port communication for example) that the device IS sending
> feedback. So the problem lies with me, not the device.
>
> Can anyone offer a fairly complete example of how I should go about
> this? PLEASE!
>
> Thanks in advance.
My System SpecsSystem Spec
Old 06-01-2009   #3 (permalink)
Alan Mailer


 
 

Re: I can WRITE thru Ethernet but can't READ from it???



On Fri, 29 May 2009 10:48:19 -0400, "John Vottero"
<JVottero@xxxxxx> wrote:
Quote:

>"Alan Mailer" <clarityassoc@xxxxxx> wrote in message
>news:bkur1553v4l4duuk37tsn97uhp0jc3a9ge@xxxxxx
Quote:

>> Please help me not tear out the last of my hair....
>>
>> I've succeeded with the code below to *WRITE* messages over LAN
>> Ethernet to a receiving device that accepts my transmitted data and
>> internally does what the data I'm sending it commands it to do:
>>
>> **********************************************************************************
>> MyTcpClient = New System.Net.Sockets.TcpClient
>> MyTcpClient.Connect(txtIPAddr.Text.ToString, CInt(txtIPPort.Text))
>> Dim nsNetstream As NetworkStream = MyTcpClient.GetStream()
>> MyNetworkStream = nsNetstream
>> Dim bytOutgoingData As Byte() = _
>> clsMyStringTranslator.HexBecomesByte("MyCommandToTheDevice")
>> MyNetworkStream.Write(bytOutgoingData, 0, bytOutgoingData.Length)
>> *********************************************************************************
>>
>> ...Now. please understand that the device I'm talking to automatically
>> sends out feedback after it has received a command. That having been
>> said... I CAN'T SEEM TO COME UP WITH A SUCESSFUL WAY OF RECIEVING THE
>> FEEDBACK!*
>>
>> I'm hoping someone reading this will take a moment or two to *spell
>> out* how I would go about this. I'm emphasizing 'spell out' because
>> I'm feeling like I need a fully-fledged example. I've tried searching
>> the web and attempted playing for several hours with TCPListeners,
>> Sockets, etc... but this stuff is relatively new to me and I must be
>> doing something wrong; even if I have been playing in the correct
>> territory.
>
>Sounds like you're making this too hard. You don't need a TCPListener or
>another socket, just do:
>
>MyNetworkStream.Read(...) or MyNetworkStream.BeginRead(...) to start an
>async read.
....Thanks for responding. I guess my question now would be: Where
would I put the '...Read' or '...BeginRead' statement? On the next
line after my '...Write' statement? How do I know the appropriate
moment to trigger a 'Read'?

AND... if I use '.BeginRead' (which I may will use; if I'm
understanding my asynchronous needs)... where would I put the
'.EndRead'?
Quote:
Quote:

>> Thanks in advance.
My System SpecsSystem Spec
Old 06-01-2009   #4 (permalink)
Matt Evans


 
 

Re: I can WRITE thru Ethernet but can't READ from it???

Yeah you could put a call to Read immediately after the Write.
Although a call to Read will block until it has read something, so you
are probably best to use BeginRead.

As for where to call EndRead, you supply a callback delegate in the
call to BeginRead which gets called asynchronously, you can call
EndRead in that callback, and it returns the number of bytes read.
Also you need to make sure you read enough data, even if the device
sends out all the data in one go, it may take several calls to Read/
BeginRead/EndRead before you have read all the data.

Matt

On Jun 2, 12:21*pm, Alan Mailer <clarityas...@xxxxxx> wrote:
Quote:

> On Fri, 29 May 2009 10:48:19 -0400, "John Vottero"
>
>
>
>
>
> <JVott...@xxxxxx> wrote:
Quote:

> >"Alan Mailer" <clarityas...@xxxxxx> wrote in message
> >news:bkur1553v4l4duuk37tsn97uhp0jc3a9ge@xxxxxx
Quote:

> >> Please help me not tear out the last of my hair....
>
Quote:
Quote:

> >> I've succeeded with the code below to *WRITE* messages over LAN
> >> Ethernet to a receiving device that accepts my transmitted data and
> >> internally does what the data I'm sending it commands it to do:
>
Quote:
Quote:

> >> ***********************************************************************************
> >> MyTcpClient = New System.Net.Sockets.TcpClient
> >> MyTcpClient.Connect(txtIPAddr.Text.ToString, CInt(txtIPPort.Text))
> >> Dim nsNetstream As NetworkStream = MyTcpClient.GetStream()
> >> MyNetworkStream = nsNetstream
> >> Dim bytOutgoingData As Byte() = _
> >> clsMyStringTranslator.HexBecomesByte("MyCommandToTheDevice")
> >> MyNetworkStream.Write(bytOutgoingData, 0, bytOutgoingData.Length)
> >> **********************************************************************************
>
Quote:
Quote:

> >> ...Now. please understand that the device I'm talking to automatically
> >> sends out feedback after it has received a command. *That having been
> >> said... I CAN'T SEEM TO COME UP WITH A SUCESSFUL WAY OF RECIEVING THE
> >> FEEDBACK!*
>
Quote:
Quote:

> >> I'm hoping someone reading this will take a moment or two to *spell
> >> out* how I would go about this. *I'm emphasizing 'spell out' because
> >> I'm feeling like I need a fully-fledged example. *I've tried searching
> >> the web and attempted playing for several hours with TCPListeners,
> >> Sockets, etc... but this stuff is relatively new to me and I must be
> >> doing something wrong; even if I have been playing in the correct
> >> territory.
>
Quote:

> >Sounds like you're making this too hard. *You don't need a TCPListeneror
> >another socket, just do:
>
Quote:

> >MyNetworkStream.Read(...) or MyNetworkStream.BeginRead(...) to start an
> >async read.
>
> ...Thanks for responding. *I guess my question now would be: Where
> would I put the '...Read' or '...BeginRead' statement? *On the next
> line after my '...Write' statement? *How do I know the appropriate
> moment to trigger a 'Read'?
>
> AND... if I use '.BeginRead' (which I may will use; if I'm
> understanding my asynchronous needs)... where would I put the
> '.EndRead'?
>
>
>
Quote:
Quote:

> >> Thanks in advance.- Hide quoted text -
>
> - Show quoted text -- Hide quoted text -
>
> - Show quoted text -
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
How to: Dual use USB drive ---> Read/Write from Computer and Read from "Stand Alone DVD Player" Vista General
read/write permissions Vista account administration
Slow SD read and write Vista hardware & devices
READ AND WRITE FOLDER FOR EVERYBODY Vista file management
DVD read/write errors Vista hardware & devices


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46