SlideShare uma empresa 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

Mais conteúdo relacionado

Destaque

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
 

Destaque (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

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 

Último (20)

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 

Notas do 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