greetings! im stuck at present due to lack of knowledge. i have the following:
public void ClientEndConnect(IAsyncResult iar)
{
try
{
CommSocket = (Socket)iar.AsyncState;
CommSocket.EndConnect(iar);
OnNetworkEvents eventArgs = new OnNetworkEvents(true, "Connected: " + CommSocket.RemoteEndPoint.ToString(), string.Empty);
OnUpdateNetworkStatusMessage(this, eventArgs);
}
catch (ArgumentNullException e)
{
OnNetworkEvents eventArgs = new OnNetworkEvents(false, "Network Unavailable", e.Message);
OnUpdateNetworkStatusMessage(this, eventArgs);
}
}
this compiles fine but as this is a callback so it should really be: (static)
public static void ClientEndConnect(IAsyncResult iar)
{
try
{
CommSocket = (Socket)iar.AsyncState;
CommSocket.EndConnect(iar);
OnNetworkEvents eventArgs = new OnNetworkEvents(true, "Connected: " + CommSocket.RemoteEndPoint.ToString(), string.Empty);
OnUpdateNetworkStatusMessage(this, eventArgs);
}
catch (ArgumentNullException e)
{
OnNetworkEvents eventArgs = new OnNetworkEvents(false, "Network Unavailable", e.Message);
OnUpdateNetworkStatusMessage(this, eventArgs);
}
)
but when i do this i get a bunch of errors like:
Error 1 An object reference is required for the non-static field, method, or property 'NietzscheBattleships.NetworkHelper.CommSocket'
due to my lack of knowledge in C# im unable to make sense of these errors. please help me understand.
im reading up on what is static but your comments would help clearing up my confusion also.