Python 3 Programming Tutorial – Sockets intro

In this Python 3 tutorial video, we cover the socket module. The socket module is a part of the standard library, so no installation is required. Sockets are an integral part for networking, but often confusing. I am by no means an expert on sockets, but I can at least share the knowledge I have on them.

Sample code for this basics series: http://pythonprogramming.net/beginner-python-programming-tutorials/

Python 3 Programming tutorial Playlist: http://www.youtube.com/watch?v=oVp1vrfL_w4&feature=share&list=PLQVvvaa0QuDe8XSftW-RAxdo6OmaeL85M

Code from this video has been adapted, updated, and ported from Python 2.7 from: http://www.binarytides.com/python-socket-programming-tutorial/

http://seaofbtc.com
http://sentdex.com
http://hkinsley.com
https://twitter.com/sentdex

Bitcoin donations: 1GV7srgR4NJx4vrk7avCmmVQQrqmv87ty6

Comments

Sk Nurul Islam says:

Hello Sir,
Can you please suggest me a book or full video series for Python socket programming…

Kari Abraham says:

THANK YOU!!!!!!!!

Vladislav Gorovenko says:

Thanks a lot for your video. I’m trying to pass the course called py4e now and on the way I’ve just stumbled across some difficulties to understand sockets and your video was a big help.

kuldeep master says:

what will request line do?

C N says:

ryan gosling is that u

hamed akbari says:

very good

Nicole Berger says:

I’d like to create a Python program that shuts down all devices on my network. (IP address space: [192,168,0,0], [192,168,255,255]) We only use Windows 7 and 10 each 64 BIT. – Who has three pupating children knows the reason … 😉

How can I change the code?

I have created the following program, but it does not work. Who can help me or write a better code?

There is the following error message:

ip = raw_input(“[[192,168,0,0],[192,168,255,255]]:”)
NameError: name ‘raw_input’ is not defined

Program Design:

import socket
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

ip = raw_input(“[[192,168,0,0],[192,168,255,255]]:”)
nachricht = raw_input(“Nachricht: Jetzt ist Schlafenszeit”)

s.sendto(nachricht, (ip, 1))
s.close()

if message == “shutdown” :
ser.close()
os.system(“shutdown -h now”)
sys.exit()
else: print(“Gute Nacht”)

Who have a better idea?

Yeshwanth Allampati says:

Hey SentDex! I have just finished your Python Basics Playlist! I have been learning from it since almost 3 days. Thanks a lot! Your explanation is simply unbelievable! I know the whole basics of python today and that’s solely because of you.

THANKS A LOT!

aayush sarna says:

What does this line means? s=socket.socket(socket.AF_INET, socket.SOCK_STREAM) What does this syntax means “socket.socket()” and socket.AF_INIT? Can’t we use just AF_INIT and Stream as parameter?

Abinay Gangireddygari says:

what kind of difference does it make to use urllib and socket module anyway?

Ian Parker says:

port 20, wat?

Vivek Teega says:

Man, you are AWESOME!! I spent the last 6 hours trying to figure out something related to sockets and this tutorial just cleared everything <3

Zero Nairo says:

mfw ftp is on 21 not 20

Ali Umair says:

you room is more organized than my life

Ali Basharat says:

Hey sentdex, I want real-time communication between a Raspberry pi device and Android application.
What should I do?
Please share your knowledge.

Behnam Anisi says:

bro you will you use 21 first then use port 20 for connection to FTP .

AL3X BLUME says:

Sentdex i need your gmail username for a tool that I coded for you I hope you will enjoy it

وسام السراج says:

I think the best way to get an IP address or using other words to resolve the server name using CMD is by using NSLOOKUP

geek programmer says:

why did u add “‘nn” in request ?

Sergio Brun says:

hi! great tutorial series. I run the code but didnt get the same output, I got this


78.41.204.27
b’HTTP/1.1 505 HTTP Version Not Supportedrnconnection: closernserver: nginxrndate: Mon, 12 Mar 2018 20:27:23 GMTrncontent-length: 0rnrn’

why is this happening?

Devilspawn RSPS says:

you’re a hell of a funny person xD

hunar omer says:

All i heared was (suck it)

NoCraft Games says:

I love your tutorials so much, very informative and an effective way to learn. keep it up man

abubakkar tahir says:

Hello sentdex thank,s for making this series can you make real chat application in python through which sender can send text and image like skype

DerTim says:

Hey I need some help! I want to write a private pyradio with sockets but I don’t know how to stream it. Could you help me?

AL3X BLUME says:

I have the tool ready just give me the email address i promise this code is not scam code

Progress says:

You are such a nice guy, you are giving us free course. Thanks :)

Write a comment

*

Human Verification: In order to verify that you are a human and not a spam bot, please enter the answer into the following box below based on the instructions contained in the graphic.


Do you like our videos?
Do you want to see more like that?

Please click below to support us on Facebook!

Send this to a friend

▷ Other ReviewsVehicles   Show Cars   Motorbikes   Scooters   Bicycles   Rims & Tires   Luxury BoatsFashion   Sunglasses   Luxury Watches   Luxury Purses   Jeans Wear   High Heels   Kinis Swimwear   Perfumes   Jewellery   Cosmetics   Shaving Helpers   Fashion Hats   Modeling TipsFooding   Chef Club   Fooding Helpers   Coktails & LiquorsSports   Sport Shoes   Fitness & Detox   Golf Gear   Racquets   Hiking & Trek Gear   Diving Equipment   Ski Gear   Snowboards   Surf Boards   Rollers & SkatesEntertainment   DIY Guides   Zik Instruments   Published Books   Music Albums   Cine Movies   Trading Helpers   Make Money   Fishing Equipment   Paintball Supplies   Trading Card Games   Telescopes   Knives   Vapes   GameplaysHigh Tech   Flat Screens   Tech Devices   Camera Lenses   Audio HiFi   Printers   USB Devices   PC Hardware   Network Gear   Cloud Servers   Software Helpers   Programmer Helpers   Mobile Apps   Hearing AidsHome   Home Furniture   Home Appliances   Tools Workshop   Beddings   Floor Layings   Barbecues   Aquarium Gear   Safe Boxes   Office Supplies   Security Locks   Cleaning ProductsKids   Baby Strollers   Child Car Seats   Remote ControlledTravel   Luggages & Bags   Airlines Seats   Hotel Rooms   Fun Trips   Cruise Ships   Mexico Tours