[HELP] port check?[Solved]

Posts 1–15 of 19 · Page 1 of 2
[HELP] port check?[Solved]
ok guys i need a little help with a project im working on for a friend its a launcher for an aion server he asked me to put a server online/offline label on it so i did the normal ping command
Code:
        If My.Computer.Network.Ping("ip here") Then
            Lable2.Visible = True
            Lable2.Text = ("Server Online")
        Else
            Lable1.Visible = True
            Lable1.Text = ("Server Offline")
        End If
which worked fine BUT we need it to check a certain port not just the ip because off that dedi there are 3 game servers running so we need to check if on the aion is up so it runs off port 7777 how can we check if only that port is online or available
localhost/ip: port

localhost:0001
192.168.0.1:0001
Quote Originally Posted by mnpeepno2 View Post
localhost/ip: port

localhost:0001
192.168.0.1:0001
wtf?
Localhost and LAN ip.. oO

anyway i still advice something more then ping. But yea sure
localhost is your computer
if you want a specific IP then put it in instead of localhost
@ mnpeepno2 i got no clue were your going
and Brinuz system.net.socket is way over my head right now any way you could explain alittle
Code:
If My.Computer.Network.Ping("ip here: port here") Then
            Lable2.Visible = True
            Lable2.Text = ("Server Online")
        Else
            Lable1.Visible = True
            Lable1.Text = ("Server Offline")
        End If
now does it make sense?
Quote Originally Posted by mnpeepno2 View Post
Code:
If My.Computer.Network.Ping("ip here: port here") Then
            Lable2.Visible = True
            Lable2.Text = ("Server Online")
        Else
            Lable1.Visible = True
            Lable1.Text = ("Server Offline")
        End If
now does it make sense?
that does not work already tried it
works for me, even in cmd.
when i add the port to the code it removes my labels so no it wont work for me and i have no clue how to do system.net.socket
Do you want to check local TCP Ports, UDP ports?
Keep in mind that TCP Ports, and UDP ports are different, Example: Just because TCP 5060 is open, doesn't mean UDP 5060 is open.

To test TCP ports, we will use System.net.sockets.

[highlight=vbnet]
Imports System.Net.Sockets
Imports System.Net
[/highlight]

[highlight=vb]
Try
Dim TCPCheck As TcpClient = New TcpClient("localhost", 5060)
Catch ex As SocketException
If (ex.ErrorCode = 10061) Then
MsgBox("The port is open and not in use")
Else
MsgBox("This port is either closed/blocked or in use")
End If
End Try

[/highlight]

You can also use this to check other machines, Just change localhost to the specific IP


I reversed that, but oh well.

here is a complete list, if you want to make a app that is fully functional and checks for just about everything, here is a list of error codes.

10004
WSAEINTR -- Interrupted function call.

10013
WSAEACCES -- Permission denied.

10014
WSAEFAULT -- Bad address.

10022
WSAEINVAL -- Invalid argument.

10024
WSAEMFILE -- Too many open files. Actually, it's too many open sockets.

10035
WSAEWOULDBLOCK -- Resource temporarily unavailable.

10036
WSAEINPROGRESS -- Operation now in progress. A blocking operation is in progress.

10037
WSAEALREADY -- Operation already in progress.

10038
WSAENOTSOCK -- Socket operation on non-socket.

10039
WSAEDESTADDRREQ -- Destination address required.

10040
WSAEMSGSIZE -- Message too long.

10041
WSAEPROTOTYPE -- Protocol wrong type for socket.

10042
WSAENOPROTOOPT -- Bad protocol option.

10043
WSAEPROTONOSUPPORT -- Protocol not supported.

10044
WSAESOCKTNOSUPPORT -- Socket type not supported.

10045
WSAEOPNOTSUPP -- Operation not supported.

10046
WSAEPFNOSUPPORT -- Protocol family not supported.

10047
WSAEAFNOSUPPORT -- Address family not supported by protocol family.

10048
WSAEADDRINUSE -- Address is already in use. If you attempt to set up a server on a port that is already is in use, you will get this error.

10049
WSAEADDRNOTAVAIL -- Cannot assign requested address.

10050
WSAENETDOWN -- Network is down.

10051
WSAENETUNREACH -- Network is unreachable.

10052
WSAENETRESET -- Network dropped connection on reset.

10053
WSAECONNABORTED -- Software caused the connection to abort. A connection that has been made was aborted, usually due to connection or protocol error.

10054
WSAECONNRESET -- Connection reset by peer. This occurs when an established connection is shut down for some reason by the remote computer.

10055
WSAENOBUFS -- No buffer space available.

10056
WSAEISCONN -- Socket is already connected.

10057
WSAENOTCONN -- Socket is not connected.

10058
WSAESHUTDOWN -- Cannot send after socket shutdown.

10060
WSAETIMEDOUT -- Connection timed out.

10061
WSAECONNREFUSED -- Connection refused. You will usually see this error when a server refuses a connection from a client, because the server is not listening on that port.

10064
WSAEHOSTDOWN -- Host is down.

10065
WSAEHOSTUNREACH -- No route to host.

10067
WSAEPROCLIM -- Too many processes.

10091
WSASYSNOTREADY -- Network subsystem is unavailable.

10092
WSAVERNOTSUPPORTED -- Unsupported version of WINSOCK.DLL.

10093
WSANOTINITIALISED -- Successful WSAStartup not yet performed. TCP networking has not been initialized on your computer.

10094
WSAEDISCON -- Graceful shutdown in progress.

11001
WSAHOST_NOT_FOUND -- Host not found. (DNS error.)

11002
WSATRY_AGAIN -- Non-authoritative host not found. Temporary DNS error.

11003
WSANO_RECOVERY -- Non-recoverable error. (DNS error.)

11004
WSANO_DATA -- Valid name, no data record of requested type. (DNS error).
You can use these to test against all possible errors thrown to land a proper result.
ok first off Ty for the help NextGen
yes im looking at a TCP port only problem with tha code is there is an error in it
'ex' is not declared. It may be inaccessible due to its protection
i hate being a C&P nub but im running out of time to finish this before the server is up and released idk if im missing something little or what sry to bug ya tho
MSN? I'll TV you...Mine is Richard@innovatorsworldwide.com

The source above works without fail, if you are getting a ex is not declared error, then you did something wrong

ex is declared, as a socket exception


Marked Solved, The issue was the game server port, it is not sending TCP errors, all other ports tested on the same and other IP's worked with the source above, he will be taking it up with the guy who owns the server (in correcting the port issue, or changing the port for the game server),

No need to post unless < 7 days & important.




ok so we decided to just run it off the login server it works all the same in the end is the conclusion we came to ty again NextGen and everyone else for the ideas
Sounds Good.
As long as the code functions and the ports are working, I am happy.

Have fun
Posts 1–15 of 19 · Page 1 of 2
This thread is closed for replies.

Tags for this Thread

None

Talk with us