jagomart
digital resources
picture1_Python Network Programming Pdf 197139 | Socket Programming


 172x       Filetype PDF       File size 0.50 MB       Source: www.csc.villanova.edu


File: Python Network Programming Pdf 197139 | Socket Programming
csc5930 9010 security and privacy in cyber physical systems socket programming using python socket programming sockets a means of sending data over a network from one application to another a ...

icon picture PDF Filetype PDF | Posted on 07 Feb 2023 | 2 years ago
Partial capture of text on file.
    CSC5930/9010: Security and Privacy in 
          Cyber-physical Systems
         Socket Programming using Python
   Socket Programming
     • Sockets
           – A means of sending data over a network from one application to another.
           – A door between application process and end-end-transport protocol
     • One socket node listens on a particular port and IP, while other socket 
         reaches out to the other to form a connection.
                                            application             socket                 application          controlled by
                                            process                                         process             app developer
                                            transport                                       transport
                                             network                                        network              controlled
                                               link                  Internet                  link              by OS
                                             physical                                       physical
                                                                                                                                                  Slide 2
  Client/server socket interaction: UDP
              server (runningon serverIP)         client
               create socket, port= x:            create socket:
               serverSocket =                     clientSocket =
               socket(AF_INET,SOCK_DGRAM)         socket(AF_INET,SOCK_DGRAM)
                                                  Create datagram with server IP and
                                                  port=x; send datagram via
                  read datagram from              clientSocket
                  serverSocket
                   write reply to
                   serverSocket                    read datagram from
                   specifying                      clientSocket
                   client address,
                   port number                     close
                                                   clientSocket
                                                                                       Slide 3
   Example app: UDP Client
                                                              Python UDPClient
                               include Python’s socket        from socket import *
                               library
                                                              serverName = ‘hostname’
                                                              serverPort = 12000
                               create UDP socket for          clientSocket = socket(AF_INET, 
                               server                                               SOCK_DGRAM)
                               get user keyboard              message = input(’Input lowercase sentence:’)
                               input                          clientSocket.sendto(str.encode(message),
                              Attach server name, port to                                 (serverName, serverPort))
                              message; send into socket
                                                              modifiedMessage, serverAddress = 
                               read reply characters from                           clientSocket.recvfrom(2048)
                               socket into string             print (bytes.decode(modifiedMessage))
                                                              clientSocket.close()
                               print out received string 
                               and close socket
                                                                                                                                     2-4     Slide 4
The words contained in this file might help you see if this file matches what you are looking for:

...Csc security and privacy in cyber physical systems socket programming using python sockets a means of sending data over network from one application to another door between process end transport protocol node listens on particular port ip while other reaches out the form connection controlled by app developer link internet os slide client server interaction udp runningon serverip create x serversocket clientsocket af inet sock dgram datagram with send via read write reply specifying address number close example udpclient include s import library servername hostname serverport for get user keyboard message input lowercase sentence sendto str encode attach name into modifiedmessage serveraddress characters recvfrom string print bytes decode received...

no reviews yet
Please Login to review.