Real Programmer
Real Programmer

Reputation: 337

what are the correct parameters for Instantiate a TCP Socket?

I need to create an instance of Socket class , But i am not sure what parameters should I parse to create TCP socket ,

    System.Net .Sockets .Socket s = new System.Net.Sockets.Socket
 (//what are the parameters required in here ?") 

Upvotes: 0

Views: 84

Answers (1)

Kas
Kas

Reputation: 3923

For tcp :

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

For Udp :

Socket s = new Socket(AddressFamily.InterNetwork, 
   SocketType.Dgram, ProtocolType.Udp);

The above code example shows you have to instantiate a socket in either way

Upvotes: 2

Related Questions