I'm struggling with something that might be really simple but goes here.
I have a method named Runerver, everything is working in it. I have another method which is called logquestion. I want to be able to use a variable set within the runover. What would be the best way?
Fixed zero runServer () {// Everything is working here, but I want to use the variable / function: string clientIP = connection.RemoteEndPoint.ToString (); } Fixed zero logRequest () {// What I want to do is the string that I created in runServer and use it here. Console.WriteLine (clientIP); } I have debuged it and it is working fine it gives an IP address but I want to be able to print that IP address on the console. Runsarvers include bus TCP listener, etc. Basic code for running the server. What I want to do is use that string within that method. I can not really take the variable client to that method, as is the connection.
Fixed zero run server (TcpListener listener); Socket connection; Networkstream socket stream; {Listener = Try New TcpListener (IPADres.ne., 43); Listener.Start (); Console.light line ("server started listening."); While (true) {connection = listener.acceptsocket (); String client IP = connection.RemoteEndPoint.ToString (); SocketStream = new network stream (connection); DoRequest (socketStream); SocketStream.Close (); Connection.Close (); }} Hold (exception e) {Console.WriteLine ("exception:" + e.ToString ()); }}
No comments:
Post a Comment