Hello,
I have following thread, that reads data from a socket.
private void RecThread()
{
int Len = 0;
byte[] input = new byte[1024];
while((Len = socket.Receive( input)) > 0) //*1
{
...
}
}
If I simply close the socket, I get an exception at *1
And I wont Abort() the thread.
How can I close the connection in a "clean" way? 2 1073
one way to do it is to create a global flag that the worker thread
check can check as it busy loops. if the flag is set, it breaks from
the loop.
"Dirk Reske" <_F*******@gmx. net> wrote in message news:<O$******* *******@TK2MSFT NGP10.phx.gbl>. .. Hello,
I have following thread, that reads data from a socket.
private void RecThread() { int Len = 0; byte[] input = new byte[1024];
while((Len = socket.Receive( input)) > 0) //*1 { ... } }
If I simply close the socket, I get an exception at *1 And I wont Abort() the thread. How can I close the connection in a "clean" way?
Catch the SocketException and quit. AFAICT, you must close the socket to
break from the blocking call. Another flag, does not do that after you are
already blocking on receive. However, you should probably loop flag
condition, that way you always check before blocking on receive again.
while ( ! stopped )
{
try
{
len = socket.Receive( input);
// etc..
}
catch( SocketException se) { break; }
}
--
William Stacey, MVP
"Dirk Reske" <_F*******@gmx. net> wrote in message
news:O$******** ******@TK2MSFTN GP10.phx.gbl... Hello,
I have following thread, that reads data from a socket.
private void RecThread() { int Len = 0; byte[] input = new byte[1024];
while((Len = socket.Receive( input)) > 0) //*1 { ... } }
If I simply close the socket, I get an exception at *1 And I wont Abort() the thread. How can I close the connection in a "clean" way?
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jesper |
last post by:
Does anyone know some c++ code for shutting down windows?
I want to write a program using borland c++ builder to shut down windows.
--
|
by: sanket gupta |
last post by:
Hi guys ,
I face a peculiar problem.
I have a mutithreaded software trhat uses sockets to connect to my
webserver.
The problem is that while my software is running , windows is unable to
reboot/logoff or shut down.
I have to shut down the software before windows can do this.
Any suggestions on why this could be happening?
Thanks/Regards
Sanket Gupta
|
by: mikelostcause |
last post by:
I'm working on shutting down an app that runs in the system tray, I have no
problems shutting down, but I have problems saving data first.
if the base.WndProc(ref m) is placed at the top, it closes, but the system
does not continue to shutdown and it does not save the data via the Logout()
funtion.
If the base.WndProc(ref m) is placed at the bottom, it closes correctly, but
doesn't seem to perform the Logout function.
protected...
|
by: Markus Stoeger |
last post by:
Hi,
I have a problem with Application.Run() when Windows is shutting down.
Please have a look at the copy&paste example program below.
The application has no forms. It has only got a notify icon in the
system tray and it uses Application.Run() to keep the message loop
running. When the user clicks the icon, the application should shut down
and exit. So far that works fine.
|
by: Mark |
last post by:
It is possible from a .NET application to prevent Windows from shutting
down?
I understand that a .NET application can "know" that windows is initiating
the process of to shutting down - but what about *preventing* that shutdown?
(and yes - I know the user can always unplug the machine)
Thanks.
| |
by: leocwh |
last post by:
Dear all,
I would like to know how to run the execuatable before windows shutting
down.
Here is my simple code:
Private Sub Command1_Click()
Shell "C:\abc.bat", vbNormalFocus
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
|
by: Jack |
last post by:
Sorry for the double post (also in the IIS group).
We've got an ASP.Net 2.0 app running on IIS6. We kept losing sessions, and
enabled health monitoring to see what was happening. This morning the got
the following in the logs. Any idea what would cause it?
Event code: 1002
Event message: Application is shutting down. Reason: Hosting environment is
shutting down.
Event time: 7/17/2007 10:28:37 AM
|
by: Larry Bud |
last post by:
Not sure where else to post this.... One of our developers quit and
I'm taking over stuff from him.
He had a COM app that would lock files on occasion (yeah, thanks for
leaving that in production instead of finding the real problem)...
anyway, the "fix" was to shut down the com app when it would lock the
file.
Any way to do that from a command line?
|
by: =?Utf-8?B?UGF1bA==?= |
last post by:
Hi I am monitoring web apps with the windows event log and noticed several
(Hosting environment is shutting down) statements. The server appears to
still be running, just wondering any ideas on what can cause this, thanks.
--
Paul G
Software engineer.
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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...
|
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,...
|
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...
|
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...
|
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();...
| |
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...
| |