SlideShare una empresa de Scribd logo
1 de 12
Using The CSharp Sockets Helper Classes
Using The CSharp Sockets Helper Classes
Using The CSharp Sockets Helper Classes
Using The CSharp Sockets Helper Classes
Using The CSharp Sockets Helper Classes
Using The CSharp Sockets Helper Classes
Using The CSharp Sockets Helper Classes
Using The CSharp Sockets Helper Classes
Using The CSharp Sockets Helper Classes
Using The CSharp Sockets Helper Classes
Using The CSharp Sockets Helper Classes
Using The CSharp Sockets Helper Classes

Más contenido relacionado

Destacado (10)

2013캄보디아
2013캄보디아2013캄보디아
2013캄보디아
 
Diabetes Health Reminders
Diabetes Health RemindersDiabetes Health Reminders
Diabetes Health Reminders
 
Network Programming in C#
Network Programming in C#Network Programming in C#
Network Programming in C#
 
Vemma
VemmaVemma
Vemma
 
Amelia earhart project 7
Amelia earhart project 7Amelia earhart project 7
Amelia earhart project 7
 
myoStream Presentation
myoStream PresentationmyoStream Presentation
myoStream Presentation
 
Store procedure
Store procedureStore procedure
Store procedure
 
Xử lý ảnh
Xử lý ảnhXử lý ảnh
Xử lý ảnh
 
Delegate và event trong C#
Delegate và event trong C#Delegate và event trong C#
Delegate và event trong C#
 
Yourprezi
YourpreziYourprezi
Yourprezi
 

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Último (20)

Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 

Notas del editor

  1. Chương trình sẽ chặn lại ở phương thức AcceptTcpClient() và chờ đợi một kết nối mới từ Client. Một khi đã kết nối rồi thì bạn sử dụng phương thức GetStream() để tạo ra một NetworkStream thực thi cho việc gửi và nhận dữ liệu trên Socket. _Lưu ý:Ta luôn luôn phải đóng NetworkStream khi xong việc như là bạn nhớ phải đóng đối tượng TcpClient khi chúng ta hoàn thành.Bạn cũng phải đóng TcpListener bằng phương thức Stop(). _Quy tắc gửi và nhận dữ liệu bạn xem lại phần trước: TcpClient. Các phương thức và thuộc tính của lớp TcpListener các bạn có thể tra cứu trong MSDN. ANY : Cung cap mot dia chi IP de chi ra rang Server phai lang nghe tren tat ca cac card mang Nguyên tắc gửi và nhận dữ liệu: _Nguyên tắc chung: Dữ liệu từ dạng String cần phải chuyển thành mảng byte trước khi được chuyển đi, vì theo nguyên lý mạng máy tính thì trên đường truyền vật lý sẽ chỉ gửi các dữ liệu dạng bit: 0 or 1. Code: string StrData="Chao Server."; byte[] data= new byte[1024]; ...... data = Encoding.ASCII.GetBytes(StrData); .....//Gửi dữ liệu đi. Khi nhận dữ liệu thì cần phải chuyển byte đó lại thành dạng String để sau đó hiển thị ra màn hình. Code: byte[] data = new byte[1024]; String Input=""; ........//Nhận dữ liệu Input= Encoding.ASCII.GetString(data,0,data.Length); Console.WriteLine(input);
  2. De tao ra mot socket : Chương trình sẽ chặn lại ở phương thức AcceptTcpClient() và chờ đợi một kết nối mới từ Client. Một khi đã kết nối rồi thì bạn sử dụng phương thức GetStream() để tạo ra một NetworkStream thực thi cho việc gửi và nhận dữ liệu trên Socket. _Lưu ý:Ta luôn luôn phải đóng NetworkStream khi xong việc như là bạn nhớ phải đóng đối tượng TcpClient khi chúng ta hoàn thành.Bạn cũng phải đóng TcpListener bằng phương thức Stop(). _Quy tắc gửi và nhận dữ liệu bạn xem lại phần trước: TcpClient. Các phương thức và thuộc tính của lớp TcpListener các bạn có thể tra cứu trong MSDN. ANY : Cung cap mot dia chi IP de chi ra rang Server phai lang nghe tren tat ca cac card mang Nguyên tắc gửi và nhận dữ liệu: _Nguyên tắc chung: Dữ liệu từ dạng String cần phải chuyển thành mảng byte trước khi được chuyển đi, vì theo nguyên lý mạng máy tính thì trên đường truyền vật lý sẽ chỉ gửi các dữ liệu dạng bit: 0 or 1. Code: string StrData="Chao Server."; byte[] data= new byte[1024]; ...... data = Encoding.ASCII.GetBytes(StrData); .....//Gửi dữ liệu đi. Khi nhận dữ liệu thì cần phải chuyển byte đó lại thành dạng String để sau đó hiển thị ra màn hình. Code: byte[] data = new byte[1024]; String Input=""; ........//Nhận dữ liệu Input= Encoding.ASCII.GetString(data,0,data.Length); Console.WriteLine(input);
  3. Khi một đối tượng TcpListener được tạo ra thì bạn có thể bắt đầu lắng nghe các kết nối, sử dụng phương thức Start(). _Sau phương thức Start(), bạn phải sử dụng 1 trong 2 phương thức AcceptSocket() hoặc AcceptTcpClient() để chấp nhận các kết nối. Như bạn nhìn thấy, có 2 phương thức chấp nhận các kết nối và trả về 1 đối tượng Socket hoặc TcpClient. Chương trình sẽ chặn lại ở phương thức AcceptTcpClient() và chờ đợi một kết nối mới từ Client. Một khi đã kết nối rồi thì bạn sử dụng phương thức GetStream() để tạo ra một NetworkStream thực thi cho việc gửi và nhận dữ liệu trên Socket. _Lưu ý:Ta luôn luôn phải đóng NetworkStream khi xong việc như là bạn nhớ phải đóng đối tượng TcpClient khi chúng ta hoàn thành.Bạn cũng phải đóng TcpListener bằng phương thức Stop(). _Quy tắc gửi và nhận dữ liệu bạn xem lại phần trước: TcpClient. Các phương thức và thuộc tính của lớp TcpListener các bạn có thể tra cứu trong MSDN. ANY : Cung cap mot dia chi IP de chi ra rang Server phai lang nghe tren tat ca cac card mang Nguyên tắc gửi và nhận dữ liệu: _Nguyên tắc chung: Dữ liệu từ dạng String cần phải chuyển thành mảng byte trước khi được chuyển đi, vì theo nguyên lý mạng máy tính thì trên đường truyền vật lý sẽ chỉ gửi các dữ liệu dạng bit: 0 or 1. Code: string StrData="Chao Server."; byte[] data= new byte[1024]; ...... data = Encoding.ASCII.GetBytes(StrData); .....//Gửi dữ liệu đi. Khi nhận dữ liệu thì cần phải chuyển byte đó lại thành dạng String để sau đó hiển thị ra màn hình. Code: byte[] data = new byte[1024]; String Input=""; ........//Nhận dữ liệu Input= Encoding.ASCII.GetString(data,0,data.Length); Console.WriteLine(input);
  4. Khi một đối tượng TcpListener được tạo ra thì bạn có thể bắt đầu lắng nghe các kết nối, sử dụng phương thức Start(). _Sau phương thức Start(), bạn phải sử dụng 1 trong 2 phương thức AcceptSocket() hoặc AcceptTcpClient() để chấp nhận các kết nối. Như bạn nhìn thấy, có 2 phương thức chấp nhận các kết nối và trả về 1 đối tượng Socket hoặc TcpClient. . Chương trình sẽ chặn lại ở phương thức AcceptTcpClient() và chờ đợi một kết nối mới từ Client. Một khi đã kết nối rồi thì bạn sử dụng phương thức GetStream() để tạo ra một NetworkStream thực thi cho việc gửi và nhận dữ liệu trên Socket. _Lưu ý:Ta luôn luôn phải đóng NetworkStream khi xong việc như là bạn nhớ phải đóng đối tượng TcpClient khi chúng ta hoàn thành.Bạn cũng phải đóng TcpListener bằng phương thức Stop(). _Quy tắc gửi và nhận dữ liệu bạn xem lại phần trước: TcpClient. Các phương thức và thuộc tính của lớp TcpListener các bạn có thể tra cứu trong MSDN. ANY : Cung cap mot dia chi IP de chi ra rang Server phai lang nghe tren tat ca cac card mang Nguyên tắc gửi và nhận dữ liệu: _Nguyên tắc chung: Dữ liệu từ dạng String cần phải chuyển thành mảng byte trước khi được chuyển đi, vì theo nguyên lý mạng máy tính thì trên đường truyền vật lý sẽ chỉ gửi các dữ liệu dạng bit: 0 or 1. Code: string StrData="Chao Server."; byte[] data= new byte[1024]; ...... data = Encoding.ASCII.GetBytes(StrData); .....//Gửi dữ liệu đi. Khi nhận dữ liệu thì cần phải chuyển byte đó lại thành dạng String để sau đó hiển thị ra màn hình. Code: byte[] data = new byte[1024]; String Input=""; ........//Nhận dữ liệu Input= Encoding.ASCII.GetString(data,0,data.Length); Console.WriteLine(input);
  5. ANY : Cung cap mot dia chi IP de chi ra rang Server phai lang nghe tren tat ca cac card mang Nguyên tắc gửi và nhận dữ liệu: _Nguyên tắc chung: Dữ liệu từ dạng String cần phải chuyển thành mảng byte trước khi được chuyển đi, vì theo nguyên lý mạng máy tính thì trên đường truyền vật lý sẽ chỉ gửi các dữ liệu dạng bit: 0 or 1. Code: string StrData="Chao Server."; byte[] data= new byte[1024]; ...... data = Encoding.ASCII.GetBytes(StrData); .....//Gửi dữ liệu đi. Khi nhận dữ liệu thì cần phải chuyển byte đó lại thành dạng String để sau đó hiển thị ra màn hình. Code: byte[] data = new byte[1024]; String Input=""; ........//Nhận dữ liệu Input= Encoding.ASCII.GetString(data,0,data.Length); Console.WriteLine(input);
  6. ANY : Cung cap mot dia chi IP de chi ra rang Server phai lang nghe tren tat ca cac card mang Nguyên tắc gửi và nhận dữ liệu: _Nguyên tắc chung: Dữ liệu từ dạng String cần phải chuyển thành mảng byte trước khi được chuyển đi, vì theo nguyên lý mạng máy tính thì trên đường truyền vật lý sẽ chỉ gửi các dữ liệu dạng bit: 0 or 1. Code: string StrData="Chao Server."; byte[] data= new byte[1024]; ...... data = Encoding.ASCII.GetBytes(StrData); .....//Gửi dữ liệu đi. Khi nhận dữ liệu thì cần phải chuyển byte đó lại thành dạng String để sau đó hiển thị ra màn hình. Code: byte[] data = new byte[1024]; String Input=""; ........//Nhận dữ liệu Input= Encoding.ASCII.GetString(data,0,data.Length); Console.WriteLine(input);
  7. ANY : Cung cap mot dia chi IP de chi ra rang Server phai lang nghe tren tat ca cac card mang Nguyên tắc gửi và nhận dữ liệu: _Nguyên tắc chung: Dữ liệu từ dạng String cần phải chuyển thành mảng byte trước khi được chuyển đi, vì theo nguyên lý mạng máy tính thì trên đường truyền vật lý sẽ chỉ gửi các dữ liệu dạng bit: 0 or 1. Code: string StrData="Chao Server."; byte[] data= new byte[1024]; ...... data = Encoding.ASCII.GetBytes(StrData); .....//Gửi dữ liệu đi. Khi nhận dữ liệu thì cần phải chuyển byte đó lại thành dạng String để sau đó hiển thị ra màn hình. Code: byte[] data = new byte[1024]; String Input=""; ........//Nhận dữ liệu Input= Encoding.ASCII.GetString(data,0,data.Length); Console.WriteLine(input); Phuong thuc send co 3 phuong dang : Neu Udpclient ket noi voi 1 host o xa thi send() ko can chi dinh dich cua du lieu + nguoc lai thi phai ch idinh dich