Mang May Tinh

  • June 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Mang May Tinh as PDF for free.

More details

  • Words: 191
  • Pages: 3
Nguoi dung nhap tu client den server Server AfxSocketInit(NULL); CSocket a,b; a.Create(12345); a.Listen(); a.Accept(b); char chuoi[20]; printf("toi day"); b.Receive(chuoi,sizeof(chuoi),0); puts(chuoi); CLIENT AfxSocketInit(NULL);(“”) CSocket ketnoi; ketnoi.Create(); if(!ketnoi.Connect("172.29.50.22",12345)) { printf("loi ket noi"); return 0; } char chuoi[20]; strcpy(chuoi,"hello server"); printf("toi day"); gets(chuoi); ketnoi.Send(chuoi,sizeof(chuoi),0); (server gui chuoi den client) SERVER AfxSocketInit(NULL); CSocket a,b; a.Create(12345); a.Listen(); a.Accept(b); char chuoi[20]; /*printf("toi day"); b.Receive(chuoi,sizeof(chuoi),0); puts(chuoi);*/ strcpy(chuoi,"hello client"); b.Send(chuoi,sizeof(chuoi),0); CLIENT AfxSocketInit(NULL);(“”) CSocket ketnoi; ketnoi.Create(); if(!ketnoi.Connect("172.29.50.22",12345)) { printf("loi ket noi"); return 0; } char chuoi[20]; /*strcpy(chuoi,"hello server");

printf("toi day"); gets(chuoi); ketnoi.Send(chuoi,sizeof(chuoi),0);*/ ketnoi.Receive(chuoi,sizeof(chuoi),0); puts(chuoi); nguoi dung nhap chuoi(tu server den client) server AfxSocketInit(NULL); CSocket a,b; a.Create(12345); a.Listen(); a.Accept(b); char chuoi[20]; /*printf("toi day"); b.Receive(chuoi,sizeof(chuoi),0); puts(chuoi);*/ //strcpy(chuoi,"hello client"); gets(chuoi); b.Send(chuoi,sizeof(chuoi),0); } client AfxSocketInit(NULL); CSocket ketnoi; ketnoi.Create(); if(!ketnoi.Connect("172.29.50.22",12345)) { printf("loi ket noi"); return 0; } char chuoi[20]; /*strcpy(chuoi,"hello server"); printf("toi day"); gets(chuoi); ketnoi.Send(chuoi,sizeof(chuoi),0);*/ ketnoi.Receive(chuoi,sizeof(chuoi),0); puts(chuoi); } return nRetCode; } nguoi dung nhap chuoi tu server gui den client, va nguoc lai server AfxSocketInit(NULL); CSocket a,b; a.Create(12345); a.Listen(); a.Accept(b); char chuoi[20]; printf("Server chat: "); gets(chuoi);

b.Send(chuoi,sizeof(chuoi),0); b.Receive(chuoi, sizeof(chuoi), 0); puts(chuoi); client AfxSocketInit(NULL); CSocket ketnoi; ketnoi.Create(); if(!ketnoi.Connect("172.29.50.22",12345)) { printf("loi ket noi"); return 0; } char chuoi[20]; ketnoi.Receive(chuoi,sizeof(chuoi),0); puts(chuoi); printf("Client chat: "); gets(chuoi); ketnoi.Send(chuoi, sizeof(chuoi), 0);

Related Documents

Mang May Tinh
June 2020 12
Giai Mang May Tinh
October 2019 20
Mang May Tinh
June 2020 5
Mang May Tinh
April 2020 11
Mang May Tinh - Chuong 1
December 2019 11