Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...