473,394 Members | 2,090 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

TCPListener / GUI Responsivness

Hey guys,

A while back I posted a message about multithreading in .NET 2.0 to maintain
GUI responsivness while using a TCPListener to monitor a TCP port for
transmission. One of the MVP's in the group (Cor Ligthert) mentioned using
the queue class to do this.

I have, unfortunatly, been unable to date to figure out how to do this. (I
have achieved the project in a console application, where a GUI isnt
utilized, using the same code I show in my example below.) Does anyone have
an example, or other methods, that I can use to achieve a GUI TCPListener
implementation?

My current implementation revolves around this code (condensed):
Dim server As New TcpListener(localAddr, port)
While True 'Constant Monitor

Dim client As TcpClient = server.AcceptTcpClient()
Dim stream As NetworkStream = client.GetStream()

then break the stream down into bytes and read its contents

End While
Obviously the constant While loop is causing an unresponsive GUI, but I dont
see another way to constantly wait for a TCP message without multithreading,
and if thats the way I need to go I hope someone can provide an example for
me.

Again, thanks for the help,
chrisj
Feb 1 '06 #1
2 1608
Chris Johnson wrote:
Hey guys,

A while back I posted a message about multithreading in .NET 2.0 to maintain
GUI responsivness while using a TCPListener to monitor a TCP port for
transmission. One of the MVP's in the group (Cor Ligthert) mentioned using
the queue class to do this.

I have, unfortunatly, been unable to date to figure out how to do this. (I
have achieved the project in a console application, where a GUI isnt
utilized, using the same code I show in my example below.) Does anyone have
an example, or other methods, that I can use to achieve a GUI TCPListener
implementation?

My current implementation revolves around this code (condensed):
Dim server As New TcpListener(localAddr, port)
While True 'Constant Monitor

Dim client As TcpClient = server.AcceptTcpClient()
Dim stream As NetworkStream = client.GetStream()

then break the stream down into bytes and read its contents

End While
Obviously the constant While loop is causing an unresponsive GUI, but I dont
see another way to constantly wait for a TCP message without multithreading,
and if thats the way I need to go I hope someone can provide an example for
me.

Again, thanks for the help,
chrisj


You should launch your TCP Listener in a separate thread. This way your
GUI has it own thread and will get updates it needs.

Chris
Feb 1 '06 #2
Chris,

I thought that I had seen that Tom Shelton had been busy with the same
problem as yours.

http://groups.google.com/group/micro...r+tom+shelton&

Can you check these threads yourself?

I hope they help

Cor
Feb 1 '06 #3

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

Similar topics

1
by: zZ | last post by:
Hi All, I'm building a TCPListener as the server to accept TCPClient connections, using TCPListener.AcceptTcpClient. I'd like to retrieve client's IP after connected, but found no way to do...
2
by: Keith Langer | last post by:
I have a TCPListener which needs to listen on my LAN IP as well as the loopback address. In VS.Net 2002 the TCPListener constructor could accept the port as an argument and it automatically bound...
1
by: Doug Wyatt | last post by:
So I'll preface this with the fact that I'm a UNIX developer by training and have just recently gotten in to C# development on Windows. I'm basically running in to a problem whereby I suspect...
4
by: Rob White | last post by:
OK, so I have a TcpListener that is waiting for sockets, this piece of code: IPAddress localAddress = Dns.GetHostByName(Dns.GetHostName()).AddressList; IPEndPoint localEP = new...
2
by: Dave Coate | last post by:
Hi, I am working on a client-server app. I can get two applications to talk to each other on the same machine using 127.0.0.1, but as soon as I try it using a computer name or actual IP address...
3
by: Bjørn Eliasen | last post by:
Hi, I have an application running on all pc's in our company. Basically it is a TCPListener awaiting for sockets to connect and on connection performs the required tasks. The app works fine, but...
4
by: Thos | last post by:
I have a TcpListener that gets started from a GUI button event handler: TcpListener listener; listener = new TcpListener(IPAddress.Any, 1234); listener.Start(backLog); As soon as the third...
1
by: Darwin | last post by:
Setting a server to listen on 8080 for incoming connections. Written in VS2005 on a Multi-homed machine. I get the warning: Warning 1 'System.Net.Sockets.TcpListener.TcpListener(int)' is obsolete:...
1
by: secutos | last post by:
When a TcpListener accepts a connection, it returns a TcpClient, which allows you to recieve data. But what about TcpListener.Server.Receive? Does that also allow to receive data in the same way? Or...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...

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.