SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Andere mochten auch

2013캄보디아
2013캄보디아2013캄보디아
2013캄보디아christmh
 
Diabetes Health Reminders
Diabetes Health RemindersDiabetes Health Reminders
Diabetes Health Remindersdrglasgow2013
 
Network Programming in C#
Network Programming in C#Network Programming in C#
Network Programming in C#jvinhit
 
Amelia earhart project 7
Amelia earhart project 7Amelia earhart project 7
Amelia earhart project 7lexief23
 
myoStream Presentation
myoStream PresentationmyoStream Presentation
myoStream Presentationmyostream
 
Store procedure
Store procedureStore procedure
Store procedurejvinhit
 
Xử lý ảnh
Xử lý ảnhXử lý ảnh
Xử lý ảnhjvinhit
 
Delegate và event trong C#
Delegate và event trong C#Delegate và event trong C#
Delegate và event trong C#jvinhit
 

Andere mochten auch (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
 

Kürzlich hochgeladen

Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 

Kürzlich hochgeladen (20)

Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 

Hinweis der Redaktion

  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