473,738 Members | 1,949 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Working with TCPclient

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.Begin Read 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.BeginR ead 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!
Nov 20 '05 #1
2 3204

"Noozer" <po********@127 .0.0.1> wrote in message
news:O%******** ********@TK2MSF TNGP12.phx.gbl. ..
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.Begin Read 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.BeginR ead 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.

Nov 20 '05 #2
> > 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.Begin Read 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.BeginR ead 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.
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!
Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
9100
by: Daniel | last post by:
TcpClient close() method socket leak when i use TcpClient to open a connection, send data and close the TcpClient with myTcpClientInstance.Close(); it takes 60 seconds for the actual socket on the client machine to close per my network app the computer fills up w/ thousands of these :0 TCP foobox:8888 localhost:2188 TIME_WAIT :0 TCP foobox:8888 localhost:2189 TIME_WAIT :0 TCP foobox:8888 localhost:2190 TIME_WAIT
2
7958
by: Theo | last post by:
Hi, I am using a tcpclient and a tcplistener to send and receive packets. The client sends a packet and the listener replies with another one. I can send 2 packets and get an answer from the listener but it fails to send a third packet. I don't get any error messages. The client sends the packet successfully but it never arrives to the listener. This only happens when I send the packets one straight after the other. If I place a delay of 2...
3
3049
by: מורדי | last post by:
Hi, I'm writing a client/server application in which the client send a series of screenshots to the server to be saved using the tcpclient. in most cases the first screenshot is transmitted ok and arrives at the server but from after that i only a couple of KB from the start of the file which cases the picture to display only the very top (of the screen). All the pictures are saved at the client side before sent to the server and they...
3
28654
by: Ricardo Quintanilla | last post by:
i had a problem whom i do not know how to explain. i was using a TcpClient (System.Net.Sockets.TcpClient) object to send and receive data to an AS400 socket. Two months ago it started to work slowly, about 4 seconds between send and receive. In our production environment with hundreds of transactions it was truly costly. a while ago i changed de TcpClient object. Now i am using a Socket (System.Net.Sockets.Socket) object and it...
3
4687
by: Danny Tuppeny | last post by:
Hi all, I'm trying to send a null character as a string delimiter through a TcpClient (code below). It's to connect to this poker bot room: http://games.cs.ualberta.ca/webgames/poker/bots.html My code is as below, but I never get a response. I'm assuming my transmission is ending at the null character (the debug statement certainly only outputs up until the null character). Any ideas?
0
1971
by: Torsten Brasch | last post by:
Hi All and Happy New Year ;) I have a very strange problem with System.Net.Sockets.TcpClient(). For some reason, the number of bytes I can receive is limited to 5460 bytes. I made sure that the server really sends everything I expect it to send. I am actually sending XML messages and this limit is a pain in the ... Here is the code: -------------------------------------------------------------------------- Dim tcpclient As New...
1
4536
by: hamil | last post by:
I am having trouble using the TcpListener and TcpClient classes. At the end of this post is server code that runs, and a class whose purpose is described below. I need to know when the client closes the connection so I can exit my listener code. Here is what I have tried. First I asked MSDN and they said..
2
7529
by: craigkenisston | last post by:
I'm creating a TcpClient instance in an object which is created in a thread. I have a loop that goes about 6-7 cycles, creating the container object in each cycle and each object contains a TcpClient instance. If I run this loop without threading everything goes find. But if I do it within the thread, invariable on of the threads will fail to connect.
5
7302
by: puzzlecracker | last post by:
It looks like i need to get IPEndPoint first, but I cannot figure out from msdn the eventual obtainment of machine name and port number. Please suggest a solution. Thanks
0
9334
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9259
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9208
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6750
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6053
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4569
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3279
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2744
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2193
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.