public static bool StringToAdr(string s, netadr_t a) { if (s.EqualsIgnoreCase("localhost") || s.EqualsIgnoreCase("loopback")) { a.Set(net_local_adr); return(true); } try { String[] address = s.Split(":"); a.ip = IPAddress.Parse(address[0]); a.type = Defines.NA_IP; if (address.Length == 2) { a.port = Lib.Atoi(address[1]); } return(true); } catch (Exception e) { Com.Println(e.Message); return(false); } }
public static bool GetLoopPacket(int sock, netadr_t net_from, sizebuf_t net_message) { loopback_t loop = loopbacks[sock]; if (loop.send - loop.get > MAX_LOOPBACK) { loop.get = loop.send - MAX_LOOPBACK; } if (loop.get >= loop.send) { return(false); } int i = loop.get & (MAX_LOOPBACK - 1); loop.get++; System.Array.Copy(loop.msgs[i].data, 0, net_message.data, 0, loop.msgs[i].datalen); net_message.cursize = loop.msgs[i].datalen; net_from.Set(net_local_adr); return(true); }