Hello. I don't know how to force the closing of a blocked socket.
I have an server application that listens to a port. It works as it is very
simple, but I'm not sure about how to close the socket.
I use a thread to run the socket part, so I don't block the user interface.
If I close the application, and open again, the port is still in use.
I try to suspend the thread, but it doesn't work also.
How can I do that?
--
Regards,
Diego F. 3 2478
On Jun 28, 7:12 am, "Diego F." <diego_f...@msn.comwrote:
Hello. I don't know how to force the closing of a blocked socket.
I have an server application that listens to a port. It works as it is very
simple, but I'm not sure about how to close the socket.
I use a thread to run the socket part, so I don't block the user interface.
If I close the application, and open again, the port is still in use.
I try to suspend the thread, but it doesn't work also.
How can I do that?
When you created the thread that manages the socket, did you set the
IsBackground flag to true? If you do that, the OS will terminate your
child threads when the main application closes. http://msdn2.microsoft.com/en-us/lib...ackground.aspx
brian
On Jun 28, 7:12 am, "Diego F." <diego_f...@msn.comwrote:
If I close the application, and open again, the port is still in use.
Check out SO_REUSEADDR also, although that will treat the symptom, not
the disease.
brian
Thank you. I did that and it seems to work now.
--
Regards,
Diego F.
"brianlanning" <br**********@gmail.comwrote in message
news:11*********************@w5g2000hsg.googlegrou ps.com...
On Jun 28, 7:12 am, "Diego F." <diego_f...@msn.comwrote:
>Hello. I don't know how to force the closing of a blocked socket.
I have an server application that listens to a port. It works as it is very simple, but I'm not sure about how to close the socket.
I use a thread to run the socket part, so I don't block the user interface. If I close the application, and open again, the port is still in use.
I try to suspend the thread, but it doesn't work also.
How can I do that?
When you created the thread that manages the socket, did you set the
IsBackground flag to true? If you do that, the OS will terminate your
child threads when the main application closes.
http://msdn2.microsoft.com/en-us/lib...ackground.aspx
brian This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Jonny |
last post by:
Hi everybody,
I'm having problems with the following code:
InputStream hostIn = hostSock.getInputStream();
while (true) {
try {
iRead = hostIn.read(m_Buf);
}
|
by: Naresh Agarwal |
last post by:
Hi
I want HTTPServletResponse to *close* the socket after sending the
response. For this I'm closing the OutputStream after writing the
data. But still socket is not closed and client keeps on...
|
by: Daniel T. |
last post by:
The code below fails. Socket.accept blocks inside the thread and doesn't
let go, even after the socket was closed. From the error presented, the
socket never actually closes.
I realize that the...
|
by: drs |
last post by:
Hi,
I have a program which opens a socket server in a thread. I need for the
server to listen on the socket for a certain amount of time (say, ten
seconds or so) and then close it, and am...
|
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...
|
by: Yim |
last post by:
In below codes,
After 10 seconds, function t() was called. So far everything is ok.
Then I want to awake blocked read(). So want to exit program.
In t(), how to do?
(in t(), close(sockfd) don't...
|
by: Nuno Magalhaes |
last post by:
How can I close another socket belonging to the same application but
all know is the IP address of the client and the port number that the
server is listening on.
Sounds like a firewall I know...
|
by: rooster575 |
last post by:
I would like to force a socket closed if it is currently open.
For arguments sake, say a function failed to close a socket and another
function would like to use this same socket.
I get the...
|
by: =?Utf-8?B?TWlrZVo=?= |
last post by:
I have a sync socket application. The client is blocked with
Socket.Receive(...) in a thread, another thread calls Socket.Close(). This
unblock the blocked thread. But the socket server is still...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
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...
|
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...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
| |