hej, jag försöker efterlikna ett php-script som jag hittade på
internet
http://www.gameserver.dk/cs/csstatus.php
Men resultatet blir som e evighetsloop
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;
using System.Net.Sockets;
namespace HL
{
public class WebForm1 : Page
{
public Label strtext1;
public Label strerror;
public Label test2;
public void Hej()
{
test2.Text = "Njaså!";
IPAddress myIP = IPAddress.Parse("193.163.220.130");
IPHostEntry myHost = Dns.GetHostByAddress(myIP);
UdpClient receivingUdpClient = new UdpClient();
IPEndPoint RemoteIpEndPoint = new IPEndPoint(IPAddress.Any, 27302);
try
{
// det är denna rad som gör att det hänger sig innan den så fungerar allt
byte[] receiveBytes = receivingUdpClient.Receive(ref RemoteIpEndPoint);
}
catch ( Exception e )
{
strerror.Text = e.ToString();
}
}
public void Page_Load()
{
}
}
}
Sedan undrar jag vilken
using System.?? för att använda
Encoding.ASCII.GetString(receiveBytes); ??
I ett program använder man ju System.IO tror jag men det verkar
inte gå att använda på ASP.NET
Är jag helt ute och cyklar här ?
http://www.webforum.nu/showthread.php?s=&postid=439760#post439760
Denna är väl rätt bra att veta borde ju vara det svaret man får in i
variabeln ?
har hittat ett fel
IPEndPoint RemoteIpEndPoint = new IPEndPoint(IPAddress.Any, 27302);
Skall vara
IPEndPoint RemoteIpEndPoint = new IPEndPoint(myIp, 27302);
men det e samma fel ändå
Jag får detta felmeddelande efter ett tag
Server Application Unavailable
The web application you are attempting to access on this web server is currently unavailable. Please hit the "Refresh" button in your web browser to retry your request.
Administrator Note: An error message detailing the cause of this specific request failure can be found in the system event log of the web server. Please review this log entry to discover what caused this error to occur.
Och då har jag satt upp en egen HL-Server på min dator, hmm använder sig .NET's av någon annan port än 8080 när det gäller Sockets ?
Detta står i Events:
aspnet_wp.exe (PID: 2936) was recycled because it was suspected to be in a deadlocked state. It did not send any responses for pending requests in the last 180 seconds.
For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
renholmMedlem sedan apr. 20012 266 inlägg Har byggt ett litet programsom hämtar serverinfo fast som console applikation.
using System;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Collections;
public class Info
{
public static int Main(String[] args)
{
Console.WriteLine("Half-life Server Info");
if (args.Length == 0)
{
Console.WriteLine("Use hlstat <ip> <port>.");
return 0;
}
byte[] cmd = { 255, 255, 255, 255, 105, 110, 102, 111, 0 };
ArrayList resp = new ArrayList();
System.Text.ASCIIEncoding encode = new System.Text.ASCIIEncoding();
try
{
UdpClient udpClient;
udpClient = new UdpClient();
udpClient.Connect(args[0], Int32.Parse(args[1]));
udpClient.Send(cmd, cmd.Length);
byte[] byteRecived;
IPEndPoint ipEndPoint = new IPEndPoint(IPAddress.Any, 0);
bool done = true;
while(done)
{
byteRecived = udpClient.Receive(ref ipEndPoint);
udpClient.Close();
string[] str = encode.GetString(byteRecived, 5, byteRecived.Length - 9).Split(encode.GetChars(new byte[] {0}));
Console.WriteLine();
Console.WriteLine(" Ip:".PadRight(15,' ') + str[0]);
Console.WriteLine(" Name:".PadRight(15,' ') + str[1]);
Console.WriteLine(" Map:".PadRight(15,' ') + str[2]);
Console.WriteLine(" Game:".PadRight(15,' ') + str[4]);
Console.WriteLine(" Players:".PadRight(15,' ') + byteRecived[byteRecived.Length-3].ToString() + "/" + byteRecived[byteRecived.Length-2].ToString());
Console.WriteLine("");
done = false;
}
}
catch (Exception)
{
Console.WriteLine("An error occured! Please try again.");
}
return 0;
}
}
Koden är kanske inte 100%, bara test. Slit den med hälsa.
tack har hittat flera fel i mitt och lagt till inte lång kvar men jag kanske kan använda mig av lite info från ditt tack