public void SendMessage(MessageStruct Message, string RemoteHost) { UdpClient sendSocket = new UdpClient(RemoteHost, this.Port); byte[] output = System.Text.ASCIIEncoding.ASCII.GetBytes( string.Format("<{0}>{1} {2} {3} {4} {5} {6} {7} {8}", ((int)Message.Pri.Facility * 8) + (int)Message.Pri.Severity, 1, //1 Message.TimeStamp.ToString("yyyy-MM-ddThh:mm:ssZ"), //2 System.Environment.MachineName, //3 Message.AppName, //4 Message.ProcID, //5 Message.MsgID, //6 Message.GetStructuredDataString(), //7 Message.Message)); //8 //MAKE SURE THE FINAL BUFFER IS LESS THEN 1024 BYTES AND IF SO THEN SEND THE DATA if (output.Length < 1024) { sendSocket.Send(output, output.Length); sendSocket.Close(); } else { throw new InsufficientMemoryException("The data in which you are trying to send does not comply to syslog standards.\nThe total message size must be less then 1024 bytes."); } }
public static MessageStruct SerializeData(int dest, int cmd, global::ProtoBuf.IExtensible instance) { MemoryStream memStream = new MemoryStream(); ProtoBuf.Serializer.Serialize(memStream, instance); byte[] body = memStream.ToArray(); CMsg msg = new CMsg(); msg.dest = dest; msg.cmd = cmd; if (body != null && body.Length > 0) { msg.body = body; } //放在消息队列里面发 MessageStruct smsg = new MessageStruct(); smsg.dest = dest; smsg.cmd = cmd; smsg.body = (byte[])Serialize(msg); return(smsg); }
private void CheckReceive() { while (true) { if (_socketCon.isSocketNull()) { break; } //接收协议 byte[] data = null; int datalen = 0; if (_socketCon.Rece(ref data, ref datalen)) { MessageStruct message = MessageStruct.DeserializeData(data, datalen); sTime = message.serverTime; //分发协议 if (OnReceivedPacket != null) { OnReceivedPacket(message); } } Thread.Sleep(50); } }
private async void ViewMoneyWalletReminderCharge() { try { await Nonce.GetNonce(); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "/api/MoneyWalletReminderCharge/GetMoneyWalletReminderCharge"); var Content = ATISMobileWebApiMClassManagement.GetMobileNumber() + ";" + Hashing.GetSHA256Hash(ATISMobileWebApiMClassManagement.GetApiKey() + Nonce.CurrentNonce); request.Content = new StringContent(JsonConvert.SerializeObject(Content), Encoding.UTF8, "application/json"); HttpResponseMessage response = await HttpClientOnlyInstance.HttpClientInstance().SendAsync(request); if (response.IsSuccessStatusCode) { var content = await response.Content.ReadAsStringAsync(); MessageStruct Result = JsonConvert.DeserializeObject <MessageStruct>(content); _LblReminderCharge.Text = Result.Message1; _LblReminderChargeHeader.IsVisible = true; } else { await DisplayAlert("ATISMobile-Failed", JsonConvert.DeserializeObject <string>(response.Content.ReadAsStringAsync().Result), "تایید"); } } catch (System.Net.WebException ex) { await DisplayAlert("ATISMobile-Error", ATISMobilePredefinedMessages.ATISWebApiNotReachedMessage, "OK"); } catch (Exception ex) { await DisplayAlert("ATISMobile-Error", ex.Message, "OK"); } }
public void CloneMessage(MessageStruct clone) { dest = clone.dest; cmd = clone.cmd; serverTime = clone.serverTime; body = clone.body; }
public static void Receive(string message) { try { MessageStruct ms = JsonConvert.DeserializeObject <MessageStruct>(message); switch (ms.type) { case MessageType.setting: SettingsManager.Deal(ms.content); break; case MessageType.action: ActionManager.Deal(ms.content); break; case MessageType.nursery: NurseryManager.Deal(ms.content); break; case MessageType.logging: LoggingManager.Deal(ms.content); break; default: LoggingManager.Warn("Invalid message type"); break; } } catch (JsonException e) { LoggingManager.Warn($"Deserialize MessageSettingStruct failed:{e.Message}"); } }
static void Main(string[] args) { Console.WriteLine("Trying to inject dll into notepad.exe"); MessageStruct messageData = new MessageStruct() { Text = "Custom Message", Caption = "Custom Message Box" }; using (Injector syringe = new Injector(Process.GetProcessesByName("notepad")[0])) { syringe.InjectLibrary("Stub.dll"); Console.WriteLine("Stub.dll injected into notepad, trying to call void Initialise() with no parameters"); Console.ReadLine(); syringe.CallExport("Stub.dll", "Initialise"); Console.WriteLine("Waiting..."); Console.ReadLine(); Console.WriteLine("Trying to call InitWithMessage( PVOID ) with custom data {0}", messageData); Console.ReadLine(); syringe.CallExport("Stub.dll", "InitWithMessage", messageData); Console.WriteLine("Waiting..."); Console.ReadLine(); } Console.WriteLine("Stub.dll should be ejected"); Console.ReadLine(); }
private void doSendData(MessageStruct message) { string fit = "Msg_" + message.dest + "_" + message.cmd + "_"; if (1 == m_FilterType && !m_FilterMsg.Contains(fit)) { return; } if (2 == m_FilterType && m_FilterMsg.Contains(fit)) { return; } if (null == message.body) { Debug.Log("[ERROR] Failed to send packet, cmd:{0} msg is null"); return; } if (TcpPeerAgent.ServiceState == ENetServiceState.Running) { if (!TcpPeerAgent.SendPacket(message)) { Debug.Log("[ERROR] Failed to send packet, cmd:{0} size:{1}"); } } }
public void DeserializeData(ReceDataStruct source) { if (source == null) { return; } Stream stream = new MemoryStream(source.data, 0, source.datalen); CMsg cmsg = ProtoBuf.Serializer.Deserialize <CMsg>(stream); //消息号保存进队列 MessageStruct message = new MessageStruct(); message.cmd = cmsg.cmd; message.dest = cmsg.cmd; message.body = cmsg.body; message.serverTime = cmsg.serverTime; //分发协议去解析 if (onDispense != null) { onDispense(message); } SendreceiveManage.getInstance().PushReceData(message); Debug.Log("收到消息 dest=" + cmsg.dest + ",cmd=" + cmsg.cmd); }
private void f(NetworkMessageEventArgs A_0) { int num = A_0.get_Message().Value <int>("object"); cv n = new cv(); if ((num == this.o) && (this.n != null)) { n = this.n; this.n = null; } MessageStruct struct2 = A_0.get_Message().Struct("game"); MessageStruct struct3 = A_0.get_Message().Struct("model"); MessageStruct struct4 = A_0.get_Message().Struct("physics"); n.k = num; this.e(n, struct2); this.d(n, struct3); this.c(n, struct4); if ((struct2.Value <int>("behavior") & 0x1000) != 0) { n.l = (struct4.Value <int>("unknown") & 4) > 0; } this.e(n); this.c(n); if (this.b != null) { this.b(n); } }
public Instruction createInstruction() { List <string> percepts = new List <string>(); List <MessageStruct> ms = new List <MessageStruct>(); string action = ""; GameObject condObjectCurrent = puzzleCondObject; GameObject actionObjectCurrent = puzzleActionObject; while (condObjectCurrent != null && condObjectCurrent.activeSelf == true) { percepts.Add(condObjectCurrent.GetComponent <PuzzleScript>()._value); condObjectCurrent = condObjectCurrent.GetComponent <PuzzleScript>().nextPuzzle; } while (actionObjectCurrent != null && actionObjectCurrent.activeSelf == true) { if (actionObjectCurrent.GetComponent <PuzzleScript>().type == PuzzleScript.Type.MESSAGE) { MessageStruct message = new MessageStruct(actionObjectCurrent.GetComponent <PuzzleScript>()._value, actionObjectCurrent.GetComponent <PuzzleScript>().messageDropDown.captionText.text); ms.Add(message); } else if (actionObjectCurrent.GetComponent <PuzzleScript>().type == PuzzleScript.Type.ACTION_NON_TERMINAL) { MessageStruct message = new MessageStruct(actionObjectCurrent.GetComponent <PuzzleScript>()._value, "NONE"); ms.Add(message); } else { action = actionObjectCurrent.GetComponent <PuzzleScript>()._value; } actionObjectCurrent = actionObjectCurrent.GetComponent <PuzzleScript>().nextPuzzle; } return(new Instruction(percepts.ToArray(), ms.ToArray(), action)); }
private void b(NetworkMessageEventArgs A_0) { this.u = new o(); this.u.c = A_0.get_Message().Value <int>("merchant"); this.u.d = A_0.get_Message().Value <int>("buyCategories"); this.u.e = A_0.get_Message().Value <int>("unknown1"); this.u.f = A_0.get_Message().Value <int>("buyValue"); this.u.g = A_0.get_Message().Value <int>("unknown2"); this.u.h = A_0.get_Message().Value <float>("buyRate"); this.u.i = A_0.get_Message().Value <float>("sellRate"); int num = A_0.get_Message().Value <int>("itemCount"); for (int i = 0; i < num; i++) { cv cv = new cv(); MessageStruct struct2 = A_0.get_Message().Struct("items").Struct(i); cv.u = struct2.Value <int>("count"); cv.k = struct2.Value <int>("object"); this.e(cv, struct2.Struct("game")); cv.v = true; this.u.a(cv); } if (this.t != null) { this.t(this, null); } }
private void d(cv A_0, MessageStruct A_1) { A_0.q = true; A_0.t.Clear(); byte num = A_1.Value <byte>("paletteCount"); if (num == 0xff) { A_0.r = true; A_0.s = A_1.Value <int>("palette"); } else { A_0.r = false; MessageStruct struct2 = A_1.Struct("palettes"); for (int i = 0; i < num; i++) { bo item = new bo { a = struct2.Struct(i).Value <int>("palette"), b = struct2.Struct(i).Value <byte>("offset"), c = struct2.Struct(i).Value <byte>("length") }; A_0.t.Add(item); } } }
private void ThreadStart() { Socket ListenSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); IPEndPoint LocalEndPoint = new IPEndPoint(IPAddress.Any, 514); byte[] buffer = new byte[1024]; //BIND TO THE SOCKET SO WE CAN START READING FOR DATA ListenSocket.Bind(LocalEndPoint); while (mRunning) { try { //READ THE DATA AND IF THERE ISNT ANY DATA THEN WAIT UNTIL THERE IS EndPoint remoteEP = LocalEndPoint; int BytesRead = ListenSocket.ReceiveFrom(buffer, 0, 1024, SocketFlags.None, ref remoteEP); string msg = System.Text.ASCIIEncoding.ASCII.GetString(buffer, 0, BytesRead); //PARSE THE MESSAGE AND RAISE THE CALL BACK MessageStruct tmpReturn = new MessageStruct(msg, remoteEP); mCallback(tmpReturn); } catch (Exception e) { Console.Write(e.ToString()); } } //CLOSE THE SOCKET SINCE WE ARE DONE WITH IT ListenSocket.Close(); }
/// <summary> /// Decal ServerDispatch event handler. This is called when ac client recieves a network message. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void FilterCore_ServerDispatch(object sender, NetworkMessageEventArgs e) { try { // see https://acemulator.github.io/protocol/ for protocol documentation switch (e.Message.Type) { case 0xF658: // LoginCharacterSet S2C AccountName = e.Message.Value <string>("zonename"); int characterCount = e.Message.Value <int>("characterCount"); MessageStruct characters = e.Message.Struct("characters"); Characters.Clear(); for (int i = 0; i < characterCount; i++) { int id = characters.Struct(i).Value <int>("character"); string name = characters.Struct(i).Value <string>("name"); Characters.Add(id, name); } break; case 0xF7E1: // Login_WorldInfo ServerName = e.Message.Value <string>("server"); break; } } catch (Exception ex) { Utils.LogException(ex); } }
public void SerializeData(SendDataStruct data) { MemoryStream memStream = new MemoryStream(); ProtoBuf.Serializer.Serialize(memStream, data.instance); byte[] body = memStream.ToArray(); CMsg msg = new CMsg(); msg.dest = data.dest; msg.cmd = data.cmd; if (body != null && body.Length > 0) { msg.body = body; } //放在消息队列里面发 MessageStruct smsg = new MessageStruct(); smsg.dest = data.dest; smsg.cmd = data.cmd; smsg.body = (byte[])Serialize(msg); SendreceiveManage.getInstance().PushSendData(smsg); }
//获取消息队列第一个数据 public MessageStruct getCMsg() { //发送消息 pbnoCurr.setNull(); MessageStruct _msg = new MessageStruct(); //网络 是否有消息过来 _msg.dest = NetWorkManage.NETACCEPTED; //PBNO _msg=new PBNO(); 每一帧都new一个 也许会影响效率 if (recDataQueue.Count > 0) { _msg = recDataQueue.Dequeue(); //服务器时间 //STime = _msg.serverTime; pbnoCurr.CloneMessage(_msg); return(_msg); } return(_msg); }
public static void SendLine(MessageStruct message) { var messageString = MyAPIGateway.Utilities.SerializeToXML(message); var data = Encoding.UTF8.GetBytes(messageString); Wrapper.GameAction(() => MyAPIGateway.Multiplayer.SendMessageToOthers(7747, data)); }
/// <summary> /// Push a new message on the stack /// </summary> public void PushMessage(MessageStruct message) { _messages.Add(message); if (!gameObject.active) { Show(); } }
/// <summary> /// 初始化结果文档 /// </summary> /// <typeparam name="T">数据类型</typeparam> /// <param name="result">返回消息结果</param> /// <returns></returns> public static ResultContent <T> InitResult <T>(MessageStruct result) { return(new ResultContent <T> { Code = result.Code, Message = result.Message }); }
void Send(Socket client) { if (txtMess.Text.Trim().Length != 0) { messageStruct = new MessageStruct(txtMess.Text, "", "Server"); client.Send(Serialize(messageStruct)); rtbShowMessage.AppendText($"You : {messageStruct.Contents}\n"); } }
private void b(cv A_0, MessageStruct A_1) { int num = A_1.Value <int>("landcell"); float num2 = A_1.Value <float>("x"); float num3 = A_1.Value <float>("y"); float num4 = A_1.Value <float>("z"); A_0.w = dz.a(num2, num3, num4 / 240f, num); }
static void Main(string[] args) { Executor injector = new Executor(); string dllName = "D3DModelRipper.dll"; MessageStruct mes = new MessageStruct(); if (ProcessParameters(args, ref mes) != 0) { Console.WriteLine("Error Processing Parameters"); return; } try { injector.Inject(dllName, args[0].Substring(0, args[0].Length - 4)); } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine("Error Injecting"); return; } D3DFuncLookup d3d9Util; try { d3d9Util = new D3DHookingLibrary.D3DFuncLookup(args[0], args[1]); } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine("Error Initializing D3DHookingLibrary"); return; } IntPtr dipAddress; IntPtr setStreamSourceAddress; try { dipAddress = (IntPtr)d3d9Util.GetD3DFunction(D3DFuncLookup.D3D9Functions.DrawIndexedPrimitive); setStreamSourceAddress = (IntPtr)d3d9Util.GetD3DFunction(D3DFuncLookup.D3D9Functions.SetStreamSource); mes.dip_address = dipAddress; mes.setStreamSource_address = setStreamSourceAddress; injector.getSyringe().CallExport(dllName, "InstallHook", mes); } catch (Exception e) { Console.WriteLine(e.Message); return; } while (true) { Thread.Sleep(300); } }
private void SendBySocket() { //从消息队列中取一条消息数据 MessageStruct message = SendreceiveManage.getInstance().getWillSendData(); if (message != null && _socketCon.Send(message.body)) { Debug.Log("发送消息 dest=" + message.dest + ",cmd=" + message.cmd + " 成功 !"); } }
private void c(cv A_0, MessageStruct A_1) { int num = A_1.Value <int>("flags"); A_0.a[0xd000027] = num; if ((num & 0x8000) > 0) { this.b(A_0, A_1.Struct("position")); } }
public void ReadFromStream(MStreamReader sr) { Msg = new MessageStruct { Username = sr.ReadString(), Message = sr.ReadString(), ChannelTarget = sr.ReadString(), SenderId = sr.ReadInt32() }; }
/// <summary> /// 发送消息 /// </summary> /// <param name="SendMsg">消息内容</param> /// <returns>消息是否发送成功</returns> public bool MessageSend(MessageStruct SendMsg) { if (_udpSend == null) { return(false); } byte[] buffer = System.Text.Encoding.UTF8.GetBytes(SendMsg.ToString()); _udpSend.SendTo(buffer, _udpSendIPEndPoint); return(true); }
/// <summary> /// 获取一个消息 /// </summary> /// <returns>获取的消息如果没有则是返回NULL</returns> public MessageStruct GetWindowsMessage() { if (RecMessageList.Count > 0) { MessageStruct str = RecMessageList[0]; RecMessageList.Remove(str); return(str); } return(null); }
void Send() { if (txtMess.Text.Trim().Length != 0) { messageStruct = new MessageStruct(txtMess.Text, "", "Client"); socket.Send(Serialize(messageStruct)); txtMess.Clear(); rtbShowMessage.AppendText($"You : {messageStruct.Contents} \n"); } }
private static MessageStruct PDU(MessageType mt, string sdu) { MessageStruct pdu = new MessageStruct { type = mt, content = sdu }; return(pdu); }
public void Inject(String dll, String process) { //String dll = "C:\\Users\\emist\\Documents\\Visual Studio 2008\\Projects\\InjectDLL\\Debug\\InjectDLL.dll"; Console.WriteLine("Trying to inject " + dll + " into " + process); MessageStruct messageData = new MessageStruct() { Text = "Custom Message", Caption = "Custom Message Box" }; Process[] processes = Process.GetProcessesByName(process); Array.Sort(processes, delegate(Process x, Process y) { return -1 * (x.StartTime.CompareTo(y.StartTime)); }); syringe = new Injector(processes[0]); syringe.InjectLibrary(dll); Console.WriteLine(dll + " injected into " + process); }
static void Main(string[] args) { Executor injector = new Executor(); string dllName = "D3DModelRipper.dll"; MessageStruct mes = new MessageStruct(); if (ProcessParameters(args, ref mes) != 0) { Console.WriteLine("Error Processing Parameters"); return; } try { injector.Inject(dllName, args[0].Substring(0, args[0].Length - 4)); } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine("Error Injecting"); return; } D3DFuncLookup d3d9Util; try { d3d9Util = new D3DHookingLibrary.D3DFuncLookup(args[0], args[1]); } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine("Error Initializing D3DHookingLibrary"); return; } IntPtr dipAddress; IntPtr setStreamSourceAddress; try { dipAddress = (IntPtr)d3d9Util.GetD3DFunction(D3DFuncLookup.D3D9Functions.DrawIndexedPrimitive); setStreamSourceAddress = (IntPtr)d3d9Util.GetD3DFunction(D3DFuncLookup.D3D9Functions.SetStreamSource); mes.dip_address = dipAddress; mes.setStreamSource_address = setStreamSourceAddress; injector.getSyringe().CallExport(dllName, "InstallHook", mes); } catch (Exception e) { Console.WriteLine(e.Message); return; } while (true) Thread.Sleep(300); }
static void Main(string[] args) { Executor injector = new Executor(); string dllName = "D3DTextureRipper.dll"; injector.Inject(dllName, args[0].Substring(0, args[0].Length-4)); D3DFuncLookup d3d9Util = new D3DHookingLibrary.D3DFuncLookup(args[0], args[1]); IntPtr resetAddress = (IntPtr)d3d9Util.GetD3DFunction(D3DFuncLookup.D3D9Functions.SetTexture); MessageStruct mes = new MessageStruct() { reset_address = resetAddress}; injector.getSyringe().CallExport(dllName, "InstallHook", mes); while (true) Thread.Sleep(300); }
static void Main(string[] args) { Executor injector = new Executor(); string dllName = "D3DWindower.dll"; injector.Inject(dllName, args[0].Substring(0, args[0].Length-4)); D3DFuncLookup d3d9Util = new D3DHookingLibrary.D3DFuncLookup(args[0], args[1]); int input_width = Convert.ToInt32(args[2]); int input_height = Convert.ToInt32(args[3]); IntPtr resetAddress = (IntPtr)d3d9Util.GetD3DFunction(D3DFuncLookup.D3D9Functions.Reset); MessageStruct mes = new MessageStruct() { reset_address = resetAddress, height = input_height, width = input_width }; injector.getSyringe().CallExport(dllName, "InstallHook", mes); while (true) Thread.Sleep(300); }
static void Main(string[] args) { Console.WriteLine("Injecting into Driver.exe"); if(!InjectDLL()) { Console.WriteLine("Press any key to exit"); Console.ReadLine(); return; } Console.WriteLine("Ready to execute Lua"); while (true) { string command = Console.ReadLine(); MessageStruct messageData = new MessageStruct() { Message = command }; syringe.CallExport(LIB_NAME, "ExecuteLua", messageData); } }
static void Main(string[] args) { Console.WriteLine("Trying to inject dll into notepad.exe"); MessageStruct messageData = new MessageStruct() { Text = "Custom Message", Caption = "Custom Message Box" }; using (Injector syringe = new Injector(Process.GetProcessesByName("notepad")[0])) { syringe.InjectLibrary("Stub.dll"); Console.WriteLine("Stub.dll injected into notepad, trying to call void Initialise() with no parameters"); Console.ReadLine(); syringe.CallExport("Stub.dll", "Initialise"); Console.WriteLine("Waiting..."); Console.ReadLine(); Console.WriteLine("Trying to call InitWithMessage( PVOID ) with custom data {0}", messageData); Console.ReadLine(); syringe.CallExport("Stub.dll", "InitWithMessage", messageData); Console.WriteLine("Waiting..."); Console.ReadLine(); } Console.WriteLine("Stub.dll should be ejected"); Console.ReadLine(); }
static int ProcessParameters(string[] args, ref MessageStruct mes) { int retval = 0; if (args.Length < 4 || args.Length > 4) { Console.WriteLine("Usage: ExeName d3dX.dll PrimCount VertCount"); retval = -1; } else { try { mes.primcount = Convert.ToInt32(args[2]); mes.vertnum = Convert.ToInt32(args[3]); } catch (Exception e) { Console.WriteLine(e.Message); retval = -2; } } return retval; }
public void SendMessage(MessageStruct Message, string RemoteHost) { UdpClient sendSocket = new UdpClient(RemoteHost, this.Port); byte[] output = System.Text.ASCIIEncoding.ASCII.GetBytes(string.Format("<{0}>{1} {2}:{3}", ((int)Message.Pri.Facility * 8) + (int)Message.Pri.Severity, Message.TimeStamp.ToString("MMM dd hh:mm:ss"), System.Environment.MachineName, Message.Message)); //MAKE SURE THE FINAL BUFFER IS LESS THEN 1024 BYTES AND IF SO THEN SEND THE DATA if (output.Length < 1024) { sendSocket.Send(output, output.Length); sendSocket.Close(); } else { throw new InsufficientMemoryException("The data in which you are trying to send does not comply to syslog standards.\nThe total message size must be less then 1024 bytes."); } }
internal void Update(MessageStruct FellowStruct) { _Id = FellowStruct.Value<int>("fellow"); _Name = FellowStruct.Value<string>("name"); _Level = FellowStruct.Value<int>("level"); _MaxHealth = FellowStruct.Value<int>("maxHealth"); _MaxStamina = FellowStruct.Value<int>("maxStam"); _MaxMana = FellowStruct.Value<int>("maxMana"); _CurrentHealth = FellowStruct.Value<int>("curHealth"); _CurrentStamina = FellowStruct.Value<int>("curStam"); _CurrentMana = FellowStruct.Value<int>("curMana"); if(FellowStruct.Value<int>("shareLoot") == 0x10){_ShareLoot = true;}else{_ShareLoot = false;} }
internal void AddFellow(MessageStruct FellowStruct) { _FellowMembers.Add(new FellowMember(FellowStruct)); }
private void ThreadStart() { Socket ListenSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); IPEndPoint LocalEndPoint = new IPEndPoint(IPAddress.Any, 514); byte[] buffer = new byte[1024]; //BIND TO THE SOCKET SO WE CAN START READING FOR DATA ListenSocket.Bind(LocalEndPoint); while (mRunning) { try { //READ THE DATA AND IF THERE ISNT ANY DATA THEN WAIT UNTIL THERE IS EndPoint remoteEP = LocalEndPoint; int BytesRead = ListenSocket.ReceiveFrom(buffer, 0, 1024, SocketFlags.None, ref remoteEP); string msg = System.Text.ASCIIEncoding.ASCII.GetString(buffer, 0, BytesRead); //PARSE THE MESSAGE AND RAISE THE CALL BACK MessageStruct tmpReturn = new MessageStruct(msg, remoteEP); mCallback(tmpReturn); } catch (Exception e) { Console.Write(e.ToString()); } } //CLOSE THE SOCKET SINCE WE ARE DONE WITH IT ListenSocket.Close(); }