Hello All,
My question is about the proper way to setup a listening socket. I have the
following code that works fine:
IPAddress localAddr = Dns.GetHostEntr y(strHostName). AddressList[0];
Int32 port = 25001;
TcpListener tcpServerListen er = new TcpListener(por t);
tcpServerListen er.Start();
Socket serverSocket = tcpServerListen er.AcceptSocket ();
However, I've seen other code out there that looks like this:
this.listenerSo cket = new Socket(AddressF amily.InterNetw ork,
SocketType.Stre am, ProtocolType.Tc p);
this.listenerSo cket.Bind( new IPEndPoint(this .serverIP , this.serverPort ));
this.listenerSo cket.Listen(200 );
Is it necessary to specify the AddressFamily and SocketType or is my way ok?
Thanks,
John
My question is about the proper way to setup a listening socket. I have the
following code that works fine:
IPAddress localAddr = Dns.GetHostEntr y(strHostName). AddressList[0];
Int32 port = 25001;
TcpListener tcpServerListen er = new TcpListener(por t);
tcpServerListen er.Start();
Socket serverSocket = tcpServerListen er.AcceptSocket ();
However, I've seen other code out there that looks like this:
this.listenerSo cket = new Socket(AddressF amily.InterNetw ork,
SocketType.Stre am, ProtocolType.Tc p);
this.listenerSo cket.Bind( new IPEndPoint(this .serverIP , this.serverPort ));
this.listenerSo cket.Listen(200 );
Is it necessary to specify the AddressFamily and SocketType or is my way ok?
Thanks,
John
Comment