Raised This Month: $ Target: $400
 0% 

PHP to VB


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Process
Junior Member
Join Date: Jan 2015
Location: Banned
Old 01-17-2015 , 08:50   PHP to VB
Reply With Quote #1

How can i convert this to vb.net

PHP Code:
// Ip address and port
$_ip '127.0.0.1';
$_port '27015';
 
$socket stream_socket_client('udp://'.$_ip.':'.$_port$errno$errstr30);
stream_set_timeout($socket10);
 
// Send command to server
$cmd SERVERQUERY_GETCHALLENGE;
$length strlen($cmd);
fwrite($socket$cmd$length);
 
// Get response from server
$response fread($socketPACKET_SIZE);
 
if (empty(
$response))
{
    echo 
'Server Offline';
}
else
{
    echo 
'Server Online';


Last edited by Process; 01-17-2015 at 08:52.
Process is offline
Neeeeeeeeeel.-
Some Guy Yellin'
Join Date: Jul 2010
Location: Argentina
Old 01-17-2015 , 18:28   Re: PHP to VB
Reply With Quote #2

Maybe something like this:
PHP Code:
Dim udpClient As New UdpClient(27015)
udpClient.Connect("127.0.0.1"27015);

Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes(Chr(255) + Chr(255) + Chr(255) + Chr(255) + "TSource Engine Query")
udpClient.Send(sendBytessendBytes.Length)

Dim RemoteIpEndPoint As New IPEndPoint(IPAddress.Any0)

udpClient.ReceiveTimeout 5

Dim receiveBytes 
As [Byte]() = udpClient.Receive(RemoteIpEndPoint)
Dim returnData As String Encoding.ASCII.GetString(receiveBytes)

If 
returnData.ToString() = "" Then
    Console
.WriteLine("Server offline")
Else
    
Console.WriteLine("Server online")
EndIf

udpClient.Close() 
I did not test it... it may have some silly sintax errors because I did not use vb.NET IDE and I have not been using it for a long time.
__________________
Neeeeeeeeeel.- is offline
Send a message via Skype™ to Neeeeeeeeeel.-
Process
Junior Member
Join Date: Jan 2015
Location: Banned
Old 01-18-2015 , 08:37   Re: PHP to VB
Reply With Quote #3

Thanks a lot ! solved !
Between i don't know if the check of server is on or off is true because anyway if the server is off there is a receive ?

Edit : And for the adress.Any should be Adress.parse(Ip here,Port) anyway thanks this is what i'm looking for it !

Last edited by Process; 01-18-2015 at 08:39.
Process is offline
Neeeeeeeeeel.-
Some Guy Yellin'
Join Date: Jul 2010
Location: Argentina
Old 01-21-2015 , 13:58   Re: PHP to VB
Reply With Quote #4

Quote:
Originally Posted by Process View Post
Thanks a lot ! solved !
Between i don't know if the check of server is on or off is true because anyway if the server is off there is a receive ?

Edit : And for the adress.Any should be Adress.parse(Ip here,Port) anyway thanks this is what i'm looking for it !
If the server is offline you won't recive any response... what you don't know is if the response came from an HL server.

IPAddress.Any should stay like I put it.
__________________
Neeeeeeeeeel.- is offline
Send a message via Skype™ to Neeeeeeeeeel.-
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 03:13.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode