
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Socket Programming in C#
The System.Net.Sockets namespace has a managed implementation of the Windows Sockets interface.
It has two basic modes − synchronous and asynchronous.
Let us see an example to work with System.Net.Sockets.TcpListener class −
TcpListener l = new TcpListener(1234); l.Start(); // creating a socket Socket s = l.AcceptSocket(); Stream network = new NetworkStream(s);
The following is the Socket useful in communicating on TCP/IP network −
Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
Above,
AddressFamily − It is the standard address families by the Socket class to resolve network addresses
SocketType − The type of socket
ProtocolType − This is the network protocol for communication on the Socket. It can be Tcp and Udp.
Advertisements