G
Guest
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.GetHostEntry(strHostName).AddressList[0];
Int32 port = 25001;
TcpListener tcpServerListener = new TcpListener(port);
tcpServerListener.Start();
Socket serverSocket = tcpServerListener.AcceptSocket();
However, I've seen other code out there that looks like this:
this.listenerSocket = new Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp);
this.listenerSocket.Bind( new IPEndPoint(this.serverIP , this.serverPort));
this.listenerSocket.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.GetHostEntry(strHostName).AddressList[0];
Int32 port = 25001;
TcpListener tcpServerListener = new TcpListener(port);
tcpServerListener.Start();
Socket serverSocket = tcpServerListener.AcceptSocket();
However, I've seen other code out there that looks like this:
this.listenerSocket = new Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp);
this.listenerSocket.Bind( new IPEndPoint(this.serverIP , this.serverPort));
this.listenerSocket.Listen(200);
Is it necessary to specify the AddressFamily and SocketType or is my way ok?
Thanks,
John