Arguments for tcpListener class

Jonno

Newcomer
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 don't 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);
 
I'm 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: I'm still new at this so I'm just telling you what works for me. :)
 
Back
Top