Socket Programming

Devcult - 6G and Satellites
1 min readMay 8, 2019

--

Socket’s are a programmer’s device for transferring bytes between programs, possibly running between different computers. Although sockets themselves transfer only byte strings, we can also transfer python objects through them by using Python’s pickle module.

Python’s socket module is just a thin wrapper (interface layer) over the underlying C library’s socket calls.

This module supports all commonly used socket types- TCP/IP, UDP, datagram and unix domain. It can be used as both a network interface API and a general IPC mechanism between processes running on the same machine.

Struct is another module that can be used to format Python objects as packed binary data byte strings for transmission, but it’s scope is limited.

Besides data communication, the socket module also supports the following tasks.

  1. Converting bytes to a standard network ordering (ntohl, htonl)
  2. Querying machine name and address (gethostname, gethostbyname)
  3. Wrapping socket objects in a file object interface (sockobj.makefile)
  4. Making socket calls nonblocking (sockobj.setblocking)
  5. Setting socket timeouts (sockobj.settimeout)

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Devcult - 6G and Satellites
Devcult - 6G and Satellites

No responses yet

Write a response