473,396 Members | 2,030 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,396 software developers and data experts.

Problem on Threading and TcpListen

I have a tcpListen on a new thread in my application.
When start the tcpListen, the process will hold in that line.
I would like to terminate the tcpListen by abort the thread, but fail.

How can I abost the tcpListen in a indepent thread?

Thanks a lot!

Jan 26 '07 #1
2 931

Cylix wrote:
I have a tcpListen on a new thread in my application.
When start the tcpListen, the process will hold in that line.
I would like to terminate the tcpListen by abort the thread, but fail.

How can I abost the tcpListen in a indepent thread?

Thanks a lot
The reason you can't use Thread.Abort is that Thread.Abort is a request
to the thread to shutdown at the earlieast possible moment. If that
thread happens to be in Unmanaged code (as it is, while the socket is
in a listening state - ie a call to accept), it will not recieve that
request (a threadabortexception) until it returns from that call. So,
unless a client happens to connect you won't abort.

So, the common way to overcome that is to make sure you have a
reference to the actual listener, and then call close on it. This will
cause it to leave the listen state and then you can shutdown the
thread.

--
Tom Shelton

Jan 26 '07 #2
I have some code that can point you in the right direction. Email me and
I'll send it to you...

"Cylix" <cy*******@gmail.comwrote in message
news:11*********************@q2g2000cwa.googlegrou ps.com...
>I have a tcpListen on a new thread in my application.
When start the tcpListen, the process will hold in that line.
I would like to terminate the tcpListen by abort the thread, but fail.

How can I abost the tcpListen in a indepent thread?

Thanks a lot!

Jan 26 '07 #3

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

Similar topics

2
by: Egor Bolonev | last post by:
hi all my program terminates with error i dont know why it tells 'TypeError: run() takes exactly 1 argument (10 given)' =program==================== import os, os.path, threading, sys def...
1
by: ENetArch | last post by:
Is there a callback example for TcpListen? I don't see a way to create a trigger in .Net that would listen for socket requests and then trigger my acceptConnection (thsClient) method. BTW .. I...
9
by: esakal | last post by:
Hello, I'm programming an application based on CAB infrastructure in the client side (c# .net 2005) Since my application must be sequencally, i wrote all the code in the UI thread. my...
5
by: CCLeasing | last post by:
For an application I'm creating I want to create a 'fake' progress bar. By fake I mean a progress bar that looks like it's doing something but actually isn't. I know philosophically this isn't...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.