{simple} Exception handling & Object references

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have this line of code I want to know where to put it in my code (basically so any private function using clientSocket.Send or clientSocket.Receive will accept it):

Socket clientSocket = new Socket(AddressFamily.InterNetwork,SocketType.Stream, ProtocolType.Tcp );

so that this line of code (which is in a private function that gets called when a button is clicked):

clientSocket.Connect(new IPEndPoint(IPAddress.Parse("xx.xxx.xx.xxx"),xxxx));

won't throw this exception:

Object reference not set to an instance of an object.

I'm new to c# and would appreciate the help.

TIA, Nate
 
Back
Top