Working with TCPclient

  • Thread starter Thread starter Noozer
  • Start date Start date
N

Noozer

Hi!

Trying to get my head around working with network connectivity in VB.Net.
I've gotten a fairly decent control based on the sample in the 101VBSamples
available from Microsoft.What I'm having problems with is the
GetStream.BeginRead method. Problem is that it's all one way... My
application connects and is able to send data, but I don't have much in the
way to provide realtime data back from my control

Is GetStrem.BeginRead method a line based method? i.e. Does it wait for the
CR/LF before it fires the delegate to read the buffer?

Is there a character based equivilent method? How about being able to fire
the delegate whenever there is any data at all in the buffer?

Basically, I want to watch the data stream for specific strings and fire an
event when they happen. I also want to have a realtime input buffer that
doesn't depends on a CR/LF to add data to the buffer.

Any help is appreciated!
 
Noozer said:
Hi!

Trying to get my head around working with network connectivity in VB.Net.
I've gotten a fairly decent control based on the sample in the 101VBSamples
available from Microsoft.What I'm having problems with is the
GetStream.BeginRead method. Problem is that it's all one way... My
application connects and is able to send data, but I don't have much in the
way to provide realtime data back from my control

Is GetStrem.BeginRead method a line based method? i.e. Does it wait for the
CR/LF before it fires the delegate to read the buffer?

Is there a character based equivilent method? How about being able to fire
the delegate whenever there is any data at all in the buffer?

Basically, I want to watch the data stream for specific strings and fire an
event when they happen. I also want to have a realtime input buffer that
doesn't depends on a CR/LF to add data to the buffer.

Any help is appreciated!

It Sounds like you used the Winsock control a lot with older lanuages.. The
TCPClient Class works a whole lot differently in comparison. Have you
looked in the 101samples there should be a client Server chat program(If
there isn't let me know and I'll post some code for one). The TCPClient
class is all streams so your going to be directly working with Byte Arrays
to get anything from it, no more directly sending strings, no waiting for
CR/LF it just waits until the Buffer is filled or the other end has send all
its relevante data. There is also the Read method which will just read
bytes out of the buffer but it will sit there and hang your app if no data
is sent for awhile for Beginread is almost always your best choice.

If you're just wonder how the TCPClient works or want to see some samples
I'm sure we could find them for you. I've put quite a few things together
that uses that class.

Hope This helps some.
 
Trying to get my head around working with network connectivity in
VB.Net.
It Sounds like you used the Winsock control a lot with older lanuages.. The
TCPClient Class works a whole lot differently in comparison. Have you
looked in the 101samples there should be a client Server chat program(If
there isn't let me know and I'll post some code for one). The TCPClient
class is all streams so your going to be directly working with Byte Arrays
to get anything from it, no more directly sending strings, no waiting for
CR/LF it just waits until the Buffer is filled or the other end has send all
its relevante data. There is also the Read method which will just read
bytes out of the buffer but it will sit there and hang your app if no data
is sent for awhile for Beginread is almost always your best choice.

Thanks! Quite helpful... If I understand, I can set the buffer size to 1 and
then I can be guarranteed that there is no leftover data in the half empty
buffer? You say that it waits "until the buffer is filled or the other end
has sent all it's relevant data" - How does it know that the other end is
done sending it's data?
If you're just wonder how the TCPClient works or want to see some samples
I'm sure we could find them for you. I've put quite a few things together
that uses that class.

Appreciated, but not necessary... I'll figure it out.

Thanks again!
 
Back
Top