internal static void GetData(int start, int length) { byte[] data = new byte[length]; Buffer.BlockCopy(NetMessage.messageBuffers[256].readBuffer, start, data, 0, length); if (data[0] == 25) { string str = Encoding.UTF8.GetString(data, 5, length - 5); string hour = DateTime.Now.Hour.ToString(); if (hour.Length == 1) { hour = "0" + hour; } string min = DateTime.Now.Minute.ToString(); if (min.Length == 1) { min = "0" + min; } string sec = DateTime.Now.Second.ToString(); if (sec.Length == 1) { sec = "0" + sec; } using (StreamWriter writer = new StreamWriter("Logs\\" + DateTime.Now.Month + "-" + DateTime.Now.Day + "-" + Main.instance.Get("worldName") + ".log", true)) { writer.WriteLine("[" + hour + ":" + min + ":" + sec + "] " + str); } } else if (data[0] == 49) { string path = "Logs\\" + DateTime.Now.Month + "-" + DateTime.Now.Day + "-" + Main.instance.Get("worldName") + ".log"; if (File.Exists(path)) { using (StreamWriter writer = new StreamWriter(path, true)) { writer.WriteLine(); writer.WriteLine("*** END LOGGING ***"); writer.WriteLine(); } } using (StreamWriter writer = new StreamWriter(path, true)) { writer.WriteLine("*** BEGIN LOGGING ***"); writer.WriteLine(); } } NetHooks.OnGetData(data); }
/// <summary> /// The workhorse of the connection operation. Tries several times to /// establish a connection to the given <host, port>. If unsuccessful, /// throws an IOException indicating what went wrong. /// </summary> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: synchronized void doConnect(InetAddress address, int port, int timeout) throws java.io.IOException internal virtual void DoConnect(InetAddress address, int port, int timeout) { lock (this) { lock (FdLock) { if (!ClosePending && (Socket_Renamed == null || !Socket_Renamed.Bound)) { NetHooks.beforeTcpConnect(Fd, address, port); } } try { AcquireFD(); try { SocketConnect(address, port, timeout); /* socket may have been closed during poll/select */ lock (FdLock) { if (ClosePending) { throw new SocketException("Socket closed"); } } // If we have a ref. to the Socket, then sets the flags // created, bound & connected to true. // This is normally done in Socket.connect() but some // subclasses of Socket may call impl.connect() directly! if (Socket_Renamed != null) { Socket_Renamed.SetBound(); Socket_Renamed.SetConnected(); } } finally { ReleaseFD(); } } catch (IOException e) { Close(); throw e; } } }
/// <summary> /// Binds the socket to the specified address of the specified local port. </summary> /// <param name="address"> the address </param> /// <param name="lport"> the port </param> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: protected synchronized void bind(InetAddress address, int lport) throws java.io.IOException protected internal override void Bind(InetAddress address, int lport) { lock (this) { lock (FdLock) { if (!ClosePending && (Socket_Renamed == null || !Socket_Renamed.Bound)) { NetHooks.beforeTcpBind(Fd, address, lport); } } SocketBind(address, lport); if (Socket_Renamed != null) { Socket_Renamed.SetBound(); } if (ServerSocket_Renamed != null) { ServerSocket_Renamed.SetBound(); } } }
internal static void SendData(byte msg, string str, int n, float n2, float n3, float n4, int n5) { NetHooks.OnSendData(msg, str, n, n2, n3, n4, n5); }