SlideShare a Scribd company logo
1 of 2
Internet programming
Sockets
Write the Python code that will create a socket to connect to the server on host
rainier.kennesaw.edu that is listening on port number 54321.
Solution
Desired Program with proper comments are given below:
#!/usr/bin/python # client code to connect to server
import socket # Here we are importing the socket module
soc = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # Here we are creating the
socket
host = socket.gethostname() # here we can modify this value according to the ip of server
hostname
port = 54321 # Port on which we will connect
soc.connect((host, port)) # Here we are connecting to the host and port
print soc.recv(1024) # Printing the data receiver from server of 1024 bytes only
soc.close # closing the socket
Internet programming Sockets Write the Python code that will create a.docx

More Related Content

More from diegor62

International business is conducted outside of the home country- Natio.docx
International business is conducted outside of the home country- Natio.docxInternational business is conducted outside of the home country- Natio.docx
International business is conducted outside of the home country- Natio.docxdiegor62
 
Intermolecular Interactions Crystalline Solids K14 of 19 Part A Classi.docx
Intermolecular Interactions Crystalline Solids K14 of 19 Part A Classi.docxIntermolecular Interactions Crystalline Solids K14 of 19 Part A Classi.docx
Intermolecular Interactions Crystalline Solids K14 of 19 Part A Classi.docxdiegor62
 
Integrative Problems equire the integration of multiple concepts to fi.docx
Integrative Problems equire the integration of multiple concepts to fi.docxIntegrative Problems equire the integration of multiple concepts to fi.docx
Integrative Problems equire the integration of multiple concepts to fi.docxdiegor62
 
Insight Communications Promotes employees with good technical skills i.docx
Insight Communications Promotes employees with good technical skills i.docxInsight Communications Promotes employees with good technical skills i.docx
Insight Communications Promotes employees with good technical skills i.docxdiegor62
 
Infrared radiation is also called IR- Describe how it is different fro (1).docx
Infrared radiation is also called IR- Describe how it is different fro (1).docxInfrared radiation is also called IR- Describe how it is different fro (1).docx
Infrared radiation is also called IR- Describe how it is different fro (1).docxdiegor62
 
Infrared radiation is also called IR- Describe how it is different fro.docx
Infrared radiation is also called IR- Describe how it is different fro.docxInfrared radiation is also called IR- Describe how it is different fro.docx
Infrared radiation is also called IR- Describe how it is different fro.docxdiegor62
 
Initial Knowledge Check For each row in the table below- decide whethe.docx
Initial Knowledge Check For each row in the table below- decide whethe.docxInitial Knowledge Check For each row in the table below- decide whethe.docx
Initial Knowledge Check For each row in the table below- decide whethe.docxdiegor62
 
Is the ability of the human ear better or worse than the sonic capabil.docx
Is the ability of the human ear better or worse than the sonic capabil.docxIs the ability of the human ear better or worse than the sonic capabil.docx
Is the ability of the human ear better or worse than the sonic capabil.docxdiegor62
 
Is my half equation and ionic equation from the answer key correct- I.docx
Is my half equation and ionic equation from the answer key correct- I.docxIs my half equation and ionic equation from the answer key correct- I.docx
Is my half equation and ionic equation from the answer key correct- I.docxdiegor62
 
Inorganic Chemistry - Wurtzite vs- Rock-Salt Structures Beryllium oxid.docx
Inorganic Chemistry - Wurtzite vs- Rock-Salt Structures Beryllium oxid.docxInorganic Chemistry - Wurtzite vs- Rock-Salt Structures Beryllium oxid.docx
Inorganic Chemistry - Wurtzite vs- Rock-Salt Structures Beryllium oxid.docxdiegor62
 
Is it time for IPI to reconsider its salesforce organization by produc.docx
Is it time for IPI to reconsider its salesforce organization by produc.docxIs it time for IPI to reconsider its salesforce organization by produc.docx
Is it time for IPI to reconsider its salesforce organization by produc.docxdiegor62
 
INITIALS- 22- Which of the following represents a combustion reaction-.docx
INITIALS- 22- Which of the following represents a combustion reaction-.docxINITIALS- 22- Which of the following represents a combustion reaction-.docx
INITIALS- 22- Which of the following represents a combustion reaction-.docxdiegor62
 
Indonesian lenders are the most profitable business in the world- The.docx
Indonesian lenders are the most profitable business in the world- The.docxIndonesian lenders are the most profitable business in the world- The.docx
Indonesian lenders are the most profitable business in the world- The.docxdiegor62
 
Indicate whether the following characteristics are primarily associate.docx
Indicate whether the following characteristics are primarily associate.docxIndicate whether the following characteristics are primarily associate.docx
Indicate whether the following characteristics are primarily associate.docxdiegor62
 
In what ways are the United States and China interdependent and it thi.docx
In what ways are the United States and China interdependent and it thi.docxIn what ways are the United States and China interdependent and it thi.docx
In what ways are the United States and China interdependent and it thi.docxdiegor62
 
In view of the Rutherford model of the atom- is the relative penetrati.docx
In view of the Rutherford model of the atom- is the relative penetrati.docxIn view of the Rutherford model of the atom- is the relative penetrati.docx
In view of the Rutherford model of the atom- is the relative penetrati.docxdiegor62
 
IN112 Cl Solutione) Naming of organic compounds-according to IUPAC- wo.docx
IN112 Cl Solutione) Naming of organic compounds-according to IUPAC- wo.docxIN112 Cl Solutione) Naming of organic compounds-according to IUPAC- wo.docx
IN112 Cl Solutione) Naming of organic compounds-according to IUPAC- wo.docxdiegor62
 
In which part of the atmosphere is the ozone layer found- (B) Stratosp.docx
In which part of the atmosphere is the ozone layer found- (B) Stratosp.docxIn which part of the atmosphere is the ozone layer found- (B) Stratosp.docx
In which part of the atmosphere is the ozone layer found- (B) Stratosp.docxdiegor62
 
In which financial statement is the difference between accrual-basis n.docx
In which financial statement is the difference between accrual-basis n.docxIn which financial statement is the difference between accrual-basis n.docx
In which financial statement is the difference between accrual-basis n.docxdiegor62
 
In what ways has learning about world religions influenced the way you.docx
In what ways has learning about world religions influenced the way you.docxIn what ways has learning about world religions influenced the way you.docx
In what ways has learning about world religions influenced the way you.docxdiegor62
 

More from diegor62 (20)

International business is conducted outside of the home country- Natio.docx
International business is conducted outside of the home country- Natio.docxInternational business is conducted outside of the home country- Natio.docx
International business is conducted outside of the home country- Natio.docx
 
Intermolecular Interactions Crystalline Solids K14 of 19 Part A Classi.docx
Intermolecular Interactions Crystalline Solids K14 of 19 Part A Classi.docxIntermolecular Interactions Crystalline Solids K14 of 19 Part A Classi.docx
Intermolecular Interactions Crystalline Solids K14 of 19 Part A Classi.docx
 
Integrative Problems equire the integration of multiple concepts to fi.docx
Integrative Problems equire the integration of multiple concepts to fi.docxIntegrative Problems equire the integration of multiple concepts to fi.docx
Integrative Problems equire the integration of multiple concepts to fi.docx
 
Insight Communications Promotes employees with good technical skills i.docx
Insight Communications Promotes employees with good technical skills i.docxInsight Communications Promotes employees with good technical skills i.docx
Insight Communications Promotes employees with good technical skills i.docx
 
Infrared radiation is also called IR- Describe how it is different fro (1).docx
Infrared radiation is also called IR- Describe how it is different fro (1).docxInfrared radiation is also called IR- Describe how it is different fro (1).docx
Infrared radiation is also called IR- Describe how it is different fro (1).docx
 
Infrared radiation is also called IR- Describe how it is different fro.docx
Infrared radiation is also called IR- Describe how it is different fro.docxInfrared radiation is also called IR- Describe how it is different fro.docx
Infrared radiation is also called IR- Describe how it is different fro.docx
 
Initial Knowledge Check For each row in the table below- decide whethe.docx
Initial Knowledge Check For each row in the table below- decide whethe.docxInitial Knowledge Check For each row in the table below- decide whethe.docx
Initial Knowledge Check For each row in the table below- decide whethe.docx
 
Is the ability of the human ear better or worse than the sonic capabil.docx
Is the ability of the human ear better or worse than the sonic capabil.docxIs the ability of the human ear better or worse than the sonic capabil.docx
Is the ability of the human ear better or worse than the sonic capabil.docx
 
Is my half equation and ionic equation from the answer key correct- I.docx
Is my half equation and ionic equation from the answer key correct- I.docxIs my half equation and ionic equation from the answer key correct- I.docx
Is my half equation and ionic equation from the answer key correct- I.docx
 
Inorganic Chemistry - Wurtzite vs- Rock-Salt Structures Beryllium oxid.docx
Inorganic Chemistry - Wurtzite vs- Rock-Salt Structures Beryllium oxid.docxInorganic Chemistry - Wurtzite vs- Rock-Salt Structures Beryllium oxid.docx
Inorganic Chemistry - Wurtzite vs- Rock-Salt Structures Beryllium oxid.docx
 
Is it time for IPI to reconsider its salesforce organization by produc.docx
Is it time for IPI to reconsider its salesforce organization by produc.docxIs it time for IPI to reconsider its salesforce organization by produc.docx
Is it time for IPI to reconsider its salesforce organization by produc.docx
 
INITIALS- 22- Which of the following represents a combustion reaction-.docx
INITIALS- 22- Which of the following represents a combustion reaction-.docxINITIALS- 22- Which of the following represents a combustion reaction-.docx
INITIALS- 22- Which of the following represents a combustion reaction-.docx
 
Indonesian lenders are the most profitable business in the world- The.docx
Indonesian lenders are the most profitable business in the world- The.docxIndonesian lenders are the most profitable business in the world- The.docx
Indonesian lenders are the most profitable business in the world- The.docx
 
Indicate whether the following characteristics are primarily associate.docx
Indicate whether the following characteristics are primarily associate.docxIndicate whether the following characteristics are primarily associate.docx
Indicate whether the following characteristics are primarily associate.docx
 
In what ways are the United States and China interdependent and it thi.docx
In what ways are the United States and China interdependent and it thi.docxIn what ways are the United States and China interdependent and it thi.docx
In what ways are the United States and China interdependent and it thi.docx
 
In view of the Rutherford model of the atom- is the relative penetrati.docx
In view of the Rutherford model of the atom- is the relative penetrati.docxIn view of the Rutherford model of the atom- is the relative penetrati.docx
In view of the Rutherford model of the atom- is the relative penetrati.docx
 
IN112 Cl Solutione) Naming of organic compounds-according to IUPAC- wo.docx
IN112 Cl Solutione) Naming of organic compounds-according to IUPAC- wo.docxIN112 Cl Solutione) Naming of organic compounds-according to IUPAC- wo.docx
IN112 Cl Solutione) Naming of organic compounds-according to IUPAC- wo.docx
 
In which part of the atmosphere is the ozone layer found- (B) Stratosp.docx
In which part of the atmosphere is the ozone layer found- (B) Stratosp.docxIn which part of the atmosphere is the ozone layer found- (B) Stratosp.docx
In which part of the atmosphere is the ozone layer found- (B) Stratosp.docx
 
In which financial statement is the difference between accrual-basis n.docx
In which financial statement is the difference between accrual-basis n.docxIn which financial statement is the difference between accrual-basis n.docx
In which financial statement is the difference between accrual-basis n.docx
 
In what ways has learning about world religions influenced the way you.docx
In what ways has learning about world religions influenced the way you.docxIn what ways has learning about world religions influenced the way you.docx
In what ways has learning about world religions influenced the way you.docx
 

Recently uploaded

Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 

Recently uploaded (20)

Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 

Internet programming Sockets Write the Python code that will create a.docx

  • 1. Internet programming Sockets Write the Python code that will create a socket to connect to the server on host rainier.kennesaw.edu that is listening on port number 54321. Solution Desired Program with proper comments are given below: #!/usr/bin/python # client code to connect to server import socket # Here we are importing the socket module soc = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # Here we are creating the socket host = socket.gethostname() # here we can modify this value according to the ip of server hostname port = 54321 # Port on which we will connect soc.connect((host, port)) # Here we are connecting to the host and port print soc.recv(1024) # Printing the data receiver from server of 1024 bytes only soc.close # closing the socket