Arguments for tcpListener class

Jonno

New member
Joined
Feb 18, 2004
Messages
1
Location
Live in Cape Town
In visual studio 2003 can you no longer just use the port number as an argument?Do you have to specify an IP address, is there no way around using an IP address?
 
I dont know if this helps, but i recently use the TcpClient class with an ip and port like this:
Code:
TcpClient myclient = new TcpClient("1.2.3.4",5000);
NetworkStream ns = new NetworkStream(myclient);
StreamReader sr = new StreamReader(ns);
StreamWriter sw = new StreamWriter(sw);

sw.WriteLine("Hello Server");
sw.Flush();

string s = sr.ReadLine();
Console.WriteLine(s);
 
Im sorry, that was for the client side, .. on my server side i just use the Port number. I think you are supposed to use an IPAddress Object, but it will still work with just the port.

TcpListener listener = new Tcplistener(5000);

disclaimer: Im still new at this so Im just telling you what works for me. :)
 
Back
Top