?
Solved

hook a port

Posted on 1999-07-27
5
Medium Priority
?
136 Views
Last Modified: 2010-04-04
how can I detect when a port (winsock) is used and depending of situation close the port.
0
Comment
Question by:twineMAN
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
5 Comments
 
LVL 13

Expert Comment

by:Epsylon
ID: 1391435
You can detect if the port is available by opening it yourself. If it fails the port is in use.

It is impossible to close a port that is being used by another program.

Epsylon.
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 1391436
Put a ServerSocket on your form and try this code:

  ServerSocket1.Port := yourport;
  try
    ServerSocket1.Active := true;
  except
    ShowMessage('Port is in use');
  end;

Epsylon.
0
 
LVL 2

Expert Comment

by:mahara
ID: 1391437
that's it, i think...
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 1391438
Well, since twineMAN is not responding.....
0
 
LVL 13

Accepted Solution

by:
Epsylon earned 300 total points
ID: 1391439
It is impossible to close a port that is being used by another program.

You can detect if the port is available by opening it yourself. If it fails the port is in use.
Put a ServerSocket on your form and try this code:

  ServerSocket1.Port := yourport;
  try
    ServerSocket1.Active := true;
  except
    ShowMessage('Port is in use');
  end;
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question