|
-
Sep 17th, 2003, 11:10 AM
#1
Thread Starter
Sleep mode
Is this port open or blocked ??[Resolved]
How can I check if a speific port is open or blocked ? Don't tell me check Socket or web classes plz
Thanks
Last edited by Pirate; Sep 18th, 2003 at 05:07 PM.
-
Sep 17th, 2003, 01:03 PM
#2
Frenzied Member
Through code? There are also port scanner utilities, I use "Advanced Port Scanner", but there's a bunch of free/shareware.
-
Sep 17th, 2003, 01:27 PM
#3
Thread Starter
Sleep mode
I know there are a lot of utilities but I need some code for some reason which is part of big proj I'm working on .... . Any ideas ?
thanks
-
Sep 17th, 2003, 01:58 PM
#4
Frenzied Member
Why wouldn't you try with a socket? Seems easy enough.
-
Sep 17th, 2003, 07:19 PM
#5
Thread Starter
Sleep mode
Umm , I checked it and couldn't do anything or I'm not sure it would solve the problem so , Anyone ?
-
Sep 17th, 2003, 07:24 PM
#6
yay gay
lol
just try to host in the specified port and if u get an "port already in use" exception then it's being used......
\m/  \m/
-
Sep 17th, 2003, 07:38 PM
#7
Thread Starter
Sleep mode
Can you show me how because I've never used this class before ?
Thnanks .
-
Sep 18th, 2003, 07:26 AM
#8
yay gay
i really never done that before but tonight when i get home i can see if i can do that..it can't be too hard
\m/  \m/
-
Sep 18th, 2003, 09:05 AM
#9
I wonder how many charact
VB Code:
Dim tr As System.Net.Sockets.TcpListener = New System.Net.Sockets.TcpListener(8000) 'change 8000 to whatever port
Try
tr.Start()
Catch ex As Exception
System.Windows.Forms.MessageBox.Show(ex.ToString)
End Try
-
Sep 18th, 2003, 09:52 AM
#10
Thread Starter
Sleep mode
nemaroller , first shows blue line under 'tr' declaration , though it run with no errors . After running this code , nothing happens , after clicking 1 more time , it shows this error :
System.Net.Sockets.SocketException: Only one usage of each socket address (protocol/network address/port) is normally permitted
at System.Net.Sockets.Socket.Bind(EndPoint localEP)
at System.Net.Sockets.TcpListener.Start()
What's the problem ?
-
Sep 18th, 2003, 09:55 AM
#11
System.Net.Sockets.SocketException: Only one usage of each socket address (protocol/network address/port) is normally permitted
at System.Net.Sockets.Socket.Bind(EndPoint localEP)
at System.Net.Sockets.TcpListener.Start()
What's the problem ?
it's throwing an error because the port is in use , which is how nemaroller meant it to work ( if you get the error message, then you know the port is in use )
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
-
Sep 18th, 2003, 10:04 AM
#12
Thread Starter
Sleep mode
No , you don't get it yet. If the port is being used and I clicked the buttton , it should throw the error right away not after the second click or the third . This doesn't seem to be reliable way . I need some API stuff if possible .
Thanks
-
Sep 18th, 2003, 10:26 AM
#13
Thread Starter
Sleep mode
I tried these port numbers (1,80,81,21,8000,60000,1234) . Same error after two clicks nothing happens after 1 click !
-
Sep 18th, 2003, 11:09 AM
#14
Addicted Member
It's late and i am going home so forgive me if i am being thick-
BUT:
The first click claims the port the second is denied and an exception is generated - isn't that what your after?
Cheers...
-
Sep 18th, 2003, 11:17 AM
#15
Thread Starter
Sleep mode
Originally posted by powdir
It's late and i am going home so forgive me if i am being thick-
BUT:
The first click claims the port the second is denied and an exception is generated - isn't that what your after?
Cheers...
This error applies to all the port number I tried with . I assume port number (60000 or something like this) would be free since I've never seen an app uses this number and also larg values ranging from 2000 to 65xxx . I don't know if this make sense but....it doesn't solve the problem yet .
-
Sep 18th, 2003, 11:22 AM
#16
yay gay
sorry to say but it DOES really work..u said u tried with port 21 but do u have an ftp server?!
\m/  \m/
-
Sep 18th, 2003, 11:27 AM
#17
Thread Starter
Sleep mode
Originally posted by PT Exorcist
sorry to say but it DOES really work..u said u tried with port 21 but do u have an ftp server?!
lol , no but I was connecting to an ftp site . Did you test it to say it works ?
-
Sep 18th, 2003, 11:29 AM
#18
yay gay
OMG
Dim tr As System.Net.Sockets.TcpListener = New System.Net.Sockets.TcpListener(21) 'change 8000 to whatever port
look at it
tcpLISTENER
this is HOSTING in your computer
this is to see if u have in YOUR computer any port open
i think u didnt quite explain what u wanted..u want to check in OTHER computer right?
sorry if i am being too agressive i have an headache..sorry
\m/  \m/
-
Sep 18th, 2003, 11:34 AM
#19
Thread Starter
Sleep mode
No , I want to detect if specific port number is open or blocked . That's all about . Again , I tested the code but it doesn't work for me at least . I don't if it's me or the code or the port .
-
Sep 18th, 2003, 11:34 AM
#20
yay gay
anyways here's the code
Code:
Try
Dim ts As System.Net.Sockets.TcpClient = New System.Net.Sockets.TcpClient("127.0.0.1", 654)
Catch ex As System.Net.Sockets.SocketException
If (ex.ErrorCode = 10061) Then
MsgBox("The port isnt being used in the target machine")
End If
End Try
\m/  \m/
-
Sep 18th, 2003, 11:35 AM
#21
yay gay
Originally posted by Pirate
No , I want to detect if specific port number is open or blocked . That's all about . Again , I tested the code but it doesn't work for me at least . I don't if it's me or the code or the port .
but you want to check it in your computer or in a remote computer?
\m/  \m/
-
Sep 18th, 2003, 11:39 AM
#22
Thread Starter
Sleep mode
In my computer . ...
-
Sep 18th, 2003, 11:43 AM
#23
Thread Starter
Sleep mode
I think it just programmed to say ""The port isnt being used in the target machine" . I couldn't find any open port . I have norton antivirus but I don't think it's able to close all port and I can't believe all these ports are being used by any resource or program (0 through 65525 or so)
-
Sep 18th, 2003, 12:12 PM
#24
yay gay
using the other guy's code will check if in YOUR computer there is any port being used and yes it works, i tried with several ports and it did work.
my code checks in ANY computer(it can be remote or not) if a port is open(at least it tries to connect and if u get 10061 error code that means the computer machine refused the connection it will show the msg), then again i tried with several ports and it worked very well in all the ports
\m/  \m/
-
Sep 18th, 2003, 03:43 PM
#25
Thread Starter
Sleep mode
Originally posted by PT Exorcist
using the other guy's code will check if in YOUR computer there is any port being used and yes it works, i tried with several ports and it did work.
my code checks in ANY computer(it can be remote or not) if a port is open(at least it tries to connect and if u get 10061 error code that means the computer machine refused the connection it will show the msg), then again i tried with several ports and it worked very well in all the ports
What ports did you try ? and did you use the loopback ip or you internet IP ? for me it shows all ports I've tried are in use .
-
Sep 18th, 2003, 04:25 PM
#26
Thread Starter
Sleep mode
I used my internet IP and still same msg . Something is missing I think .
-
Sep 18th, 2003, 05:07 PM
#27
Thread Starter
Sleep mode
Actually , the error message confused me . I downloaded a tool that checks first for port opened and then I try them in my code . I found only 5 ports open and others are closed but I don't believe this . Maybe a lot of them are not configured not closed or something like this...lol
anyway it's sorted out . This code work .
VB Code:
Try
Dim ts As System.Net.Sockets.TcpClient = New System.Net.Sockets.TcpClient("127.0.0.1", 654)
Catch ex As System.Net.Sockets.SocketException
If (ex.ErrorCode = 10061) Then
MsgBox("The port [SIZE=3]is[/SIZE] being used in the target machine")
End If
End Try
Thanks everyone for the time .
-
Sep 18th, 2003, 05:09 PM
#28
yay gay
glad to see my code worked
\m/  \m/
-
Sep 26th, 2003, 04:29 PM
#29
I wonder how many charact
Originally posted by Pirate
No , you don't get it yet. If the port is being used and I clicked the buttton , it should throw the error right away not after the second click or the third . This doesn't seem to be reliable way . I need some API stuff if possible .
Thanks
It doesn't error on the first click, because that port was not in use, and my code opened a port on it. The second time around, its in use, so then it errors.
If it doesn't error on the first click, then that port is available. I guess I should have mentioned you would want to close that port (tr.Close or tr.Stop don't remember which).
-
Sep 27th, 2003, 11:47 AM
#30
Thread Starter
Sleep mode
A question just came to my mind , How does it listen to the port ? I mean , does the port need to be opend to listen to ?
-
Sep 27th, 2003, 11:55 AM
#31
yay gay
Originally posted by Pirate
A question just came to my mind , How does it listen to the port ? I mean , does the port need to be opend to listen to ?
of course
otherwise any program would read other program's port and could do anything he wanted to
\m/  \m/
-
Sep 27th, 2003, 11:59 AM
#32
Thread Starter
Sleep mode
ah cool . thx
-
Sep 28th, 2007, 07:21 AM
#33
New Member
Re: Is this port open or blocked ??[Resolved]
Hi everybody !!! This blog has been real helpful. I dont know if the thread is still alive. I might not get a reply back . Still giving it a try.
I am trying to do what "Pirate" was trying to do. The difference is, I am trying to Detect local as well as Remote PC's ports. I am trying to detect if the port (say 4000) is unblocked on the Local as well as a Remote PC. Please mind it, I am looking for bloceked/unblocked status and not open/close. Open means its in use and close means its not in use(But can be unblocked at the same time), because no service is being used on that port.
I could do Local machine port detection very well with the below mentioned code:
This works absolutely perfect guys. I installed a firewall on my local machine and tested the code. Perfect !!!
-----------------------------------------
by: nemaroller
Dim tr As System.Net.Sockets.TcpListener = New System.Net.Sockets.TcpListener(8000) 'change 8000 to whatever port
Try
tr.Start()
Catch ex As Exception
System.Windows.Forms.MessageBox.Show(ex.ToString)
End Try
--------------------------
The trouble is detecting the ports on Remote Computer
I tried using the code by PT Exorcist
--------------
Try
Dim ts As System.Net.Sockets.TcpClient = New System.Net.Sockets.TcpClient("127.0.0.1", 654)
Catch ex As System.Net.Sockets.SocketException
If (ex.ErrorCode = 10061) Then
MsgBox("The port isnt being used in the target machine")
End If
End Try
---------------
But it doesnt seem to work.
I am in a LAN connected over Switch and connected through a Router(Gateway) to the internet.
I tried to check a port on a remote machine, but without sending an access request to the remote machine, I said "The port isnt being used in the target machine"..
The code might be fine. am doing a little research on it. .
Still if you guys have any suggestion, I would really appreciate that.
I need a code for Checking if a port is blocked on Remote PC. (blocked/unblocked)
I am implementing the whole thing in C#. so C# or VB .Net would do ..
Thanks everybody,
Regards,
-
Sep 28th, 2007, 07:27 AM
#34
Re: Is this port open or blocked ??[Resolved]
Please dont push others thread.Create ur Own Thread.Normaly u wont get replies for a thread which is marked as resolved
Please mark you thread resolved using the Thread Tools as shown
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|