Network Classes

darkrunic

Newcomer
Joined
Oct 16, 2003
Messages
5
Hello all,

I'm working on getting some server/client object classes set up and I'm having some odd issues. My connection works fine when I've got all the code just sitting out in main, but when I've got it set up like it is, it throws the exception:

Unhandled Exception: System.NullReferenceException: Object reference not set to
an instance of an object.
at System.Net.Sockets.Socket.get_CleanedUp()
at System.Net.Sockets.Socket.Bind(EndPoint localEP)
at main()

my classes are:

__gc public class Server
{

static Socket* socket = new Socket(AddressFamily::InterNetwork, SocketType::Stream, ProtocolType::Tcp);
static String* localhost = Dns::GetHostName();
static IPHostEntry* host_entry = Dns::Resolve(localhost);
static IPAddress* ip = host_entry->AddressList[0];
static IPEndPoint* end_point = new IPEndPoint(ip,1337);

void Listen();

};

__gc public class Client
{

static Socket* socket = new Socket(AddressFamily::InterNetwork, SocketType::Stream, ProtocolType::Tcp);
static IPAddress* ip = IPAddress::Parse("12.208.172.197");
static IPEndPoint* end_point = new IPEndPoint(ip,1337);

void Connect();

};

Can someone possibly point me to the error in my ways? :) Thanks!

Brian
 
Back
Top