python funcional
Código:
c# sin respuestaimport socket from time import sleep def socketconnect(cmd): s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.settimeout(5) s.connect(("127.0.0.1", 28960)) packet = '\xFF\xFF\xFF\xFFrcon "%s" %s\n' %("123456", cmd) while len(packet) > 0: c = s.send(packet) packet = packet[c:] sleep(5) message = s.recv(2048) s.close() print message socketconnect("status")
Código:
using System; using System.Collections.Generic; using System.Text; using System.Net; using System.Net.Sockets; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { IPAddress host = IPAddress.Parse("127.0.0.1"); IPEndPoint hostep = new IPEndPoint(host, 28960); Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); sock.Connect(hostep); string sentence = String.Format("\xFF\xFF\xFF\xFFrcon {0} {0}\n", "123456", "status"); sock.Send(Encoding.ASCII.GetBytes(sentence)); sock.Close(); // Keep the console window open in debug mode. Console.WriteLine("Press any key to exit"); Console.ReadKey(); } } }