
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
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.
- Related Articles
- Socket programming In Python
- Socket Programming with Multi-threading in Python?
- PHP Socket context options
- Functions in C programming
- Stringstream in C++ programming
- isnormal() in C++ Programming
- Constructors in C++ Programming
- Low-level networking interface in Python (socket)
- A C Puzzle in C Programming?
- Continue Statement in C/C++ Programming
- Protect the Docker daemon socket
- Comments in C++ Programming Language
- Super Prime in c programming
- Superperfect Number in C programming
- Arithmetic Mean in C programming

Advertisements