Chapter 4 TCP 서버/클라이언트 u-Network Design Lab 3
Why Socket Programming? “To build any Networked Application” WWW ( Internet Explorer , Firefox ) FTP (Filezilla) P2P (Limewire, Bit-torrent) u-Network Design
TCP Server – Client interaction u-Network Design
Telephone Analogy Socket() – Endpoint for communication (Telephone) Bind() - Assign a unique telephone number. (Phone No) Listen() – Wait for a caller. Connect() - Dial a number. Accept() – Receive a call. Send(), Recv() – Talk. Close() – Hang up. u-Network Design
Question 1 Write a TCP Server Program to convert all received message from Client to UPPERCASE. Send the UPPERCASE message back to client. u-Network Design
Sample Output Question 1 u-Network Design
Question 2 Write a Body Mass Index (BMI) Calculator Server Program. A useful tool to estimate a healthy body weight based on how tall a person is. Developed by Adolphe Quelet(1796-1874), and was known as the Quetelet Index. Client sends Weight(kg) and Height(m) to server Server return BMI value and weight status u-Network Design
Question 2 - continue BMI ( kg/m² ) = weight in kilograms —————————— height in meters² u-Network Design BMI Weight Status < 18.5 Underweight 18.5 -24.9 Normal 25 - 29.9 Overweight >= 30 Obese
Sample Output Question 2 Enter your Height(cm): 175 Enter your Weight(kg): 68 ====================== Your BMI value: 22.204 Your weight status: Normal Enter your Height(cm): 174 Enter your Weight(kg): 80 Your BMI value: 26.424 Your weight status: Overweight ! u-Network Design
Question 3 Modify FileSender.cpp to display % of data has been sent. 20% data has been transferred successfully. 50% data has been transferred successfully. 78% data has been transferred successfully. 89% data has been transferred successfully. 100% data has been transferred successfully. File transfer success ! u-Network Design
Thank you u-Network Design