| | | | | Welcome to XboxMB - Xbox Message Boards | | Home of the Ultimate Xbox 360 Modding Tool, Horizon. XboxMB.com is a community of Xbox 360 gamers and modders who share Tutorials, News, Reviews, and other resources. Xbox Message Boards is free to sign up and use, so what are you waiting for? Register Now! | | | | |  |
02-25-2011
|
#1 (permalink)
| | | Humph. Join Date: Sep 2010
Posts: 2,742
Thanks: 3,507 | | | [VB.NET/C#] Check Minecraft Server Status [Snippet] Very simple snippet I whipped up, figured I would share with you all. Imports: C# PHP Code: using System.Net.Sockets;
VB.NET PHP Code: Imports System.Net.Sockets
Functions: C# PHP Code: public object CheckStatus() { TcpClient MinecraftServer = new TcpClient(); try { MinecraftServer.Connect("IP/DNS to server Here", 25565); return true; } catch (Exception Excep) { return false; } }
VB.NET: PHP Code: Public Function CheckStatus() Dim MinecraftServer As New TcpClient Try MinecraftServer.Connect("IP/DNS to server Here", 25565) Return True Catch Excep As Exception Return False End Try End Function
Last edited by Kink; 02-25-2011 at 04:02 PM.
| | | |  |
02-25-2011
|
#2 (permalink)
| Regular Member | | Join Date: Sep 2010
Posts: 1,977
Thanks: 1,301 | | | Re: [VB.NET/C#] Check Minecraft Server Status [Snippet] Haha! Idea.  I'm gonna make a little tool.
EDIT: I'm done with it, I'll put it up tomorrow. Couldn't figure out how to get it to let you put your own port in, too, but I did get it so you can put in your own ip. I'll have to look into that.
Last edited by Jeremy Q; 02-26-2011 at 01:00 AM.
| | | |  |
02-26-2011
|
#3 (permalink)
| | | Humph. Join Date: Sep 2010
Posts: 2,742
Thanks: 3,507 | | | Re: [VB.NET/C#] Check Minecraft Server Status [Snippet] Quote:
Originally Posted by lee74saurus r3x Haha! Idea.  I'm gonna make a little tool.
EDIT: I'm done with it, I'll put it up tomorrow. Couldn't figure out how to get it to let you put your own port in, too, but I did get it so you can put in your own ip. I'll have to look into that. | Just edit the port where the 25565 is, put yours in there. pretty simple  . | | | |  |
02-26-2011
|
#4 (permalink)
| Regular Member | | Join Date: Sep 2010
Posts: 1,977
Thanks: 1,301 | | | Re: [VB.NET/C#] Check Minecraft Server Status [Snippet] I tried that, and I mean user input via a textbox for the port as well as the ip. It only lets me do an input for the ip or the port. Not both. When I do both it comes up with an error. And I'm gonna post it right now | | | |  |
02-26-2011
|
#5 (permalink)
| | | sh042067 Join Date: Sep 2010 Location: NY
Posts: 1,676
Thanks: 1,014 | | | Re: [VB.NET/C#] Check Minecraft Server Status [Snippet] Try parsing the textbox's text into an int: Code: MinecraftServer.Connect("IP/DNS to server Here", int.Parse(YourTextBox.Text)); | | | |  |
02-26-2011
|
#6 (permalink)
| | | Join Date: Oct 2010 Location: UK
Posts: 1,071
Thanks: 1,464 | | | Re: [VB.NET/C#] Check Minecraft Server Status [Snippet] Quote:
Originally Posted by lee74saurus r3x I tried that, and I mean user input via a textbox for the port as well as the ip. It only lets me do an input for the ip or the port. Not both. When I do both it comes up with an error. And I'm gonna post it right now  | That's cause the IP and port are seperate, you'd want something like this: PHP Code: bool CheckServer(string server) { try { new TcpClient().Connect(server.Split(':')[0], int.Parse(server.Split(':')[1])); return true; } catch{ return false; } }
Then use like: PHP Code: MessageBox.Show("Server" + CheckServer("google.com:25565") ? "Online!" : "Offline");
| | | |  |
02-26-2011
|
#7 (permalink)
| Regular Member | | Join Date: Sep 2010
Posts: 1,977
Thanks: 1,301 | | | Re: [VB.NET/C#] Check Minecraft Server Status [Snippet] Quote:
Originally Posted by sh042067 Try parsing the textbox's text into an int: Code: MinecraftServer.Connect("IP/DNS to server Here", int.Parse(YourTextBox.Text)); | Thanks! That worked! I'll reupload in a bit. | | | |  |
02-26-2011
|
#8 (permalink)
| Regular Member | | Join Date: Sep 2010
Posts: 1,977
Thanks: 1,301 | | | Re: [VB.NET/C#] Check Minecraft Server Status [Snippet] Bam. Check it out, I'm going to try to add some more things! | | | | | Thread Tools | | | | Display Modes | Linear Mode |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | All times are GMT -5. The time now is 02:06 PM. | | | | | | Powered by vBulletin® Copyright ©2000 - 2010, Jelsoft Enterprises Ltd. COPYRIGHT (c) 2010 - 2013 - XboxMB - DESIGN BY: EDENWEBS.COM | | | | |