Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python socket backlog

#Below, you see a python program that acts as a server listening for connection requests to port 9999:

# server.py 
import socket                                         
import time

# create a socket object
serversocket = socket.socket(
            socket.AF_INET, socket.SOCK_STREAM) 

# get local machine name
host = socket.gethostname()                           

port = 9999                                           

# bind to the port
serversocket.bind((host, port))                                  

# queue up to 5 requests
serversocket.listen(5)                                           

while True:
    # establish a connection
    clientsocket,addr = serversocket.accept()      

    print("Got a connection from %s" % str(addr))
    currentTime = time.ctime(time.time()) + "
"
    clientsocket.send(currentTime.encode('ascii'))
    clientsocket.close()
    
    
#The questions is what is the function of the parameter of socket.listen() method (i.e. 5).

#Based on the tutorials around the internet:
#The backlog argument specifies the maximum number of queued connections and should be at least 0; the maximum value is system-dependent (usually 5), the minimum value is forced to 0.
Comment

PREVIOUS NEXT
Code Example
Python :: jsfakjfkjadjfksajfa 
Python :: Filling a missing value in a pandas data frame with an if statement based on a condition 
Python :: python QFileDialog select files 
Python :: _tkinter.TclError: invalid command name ".!canvas" 
Python :: sqlalchemy validation at db level 
Python :: python json string indices must be integersAdd Answer 
Python :: self.stdout.write django 
Python :: how to scrape data from github api python 
Python :: ring Delete Item From List 
Python :: ring retrieves the list of all algorithms supported by Encrypt()/Decrypt() functions. 
Python :: python print replace old print 
Python :: list slicing 
Python :: ring Desktop, WebAssembly and Mobile Using QTreeView and QFileSystemModel 
Python :: Python soma números 
Python :: py3 identify file extension 
Python :: convert python code to c++ online 
Python :: unable to access jupiter assertions 
Python :: Matplotlib-Object oriented interface 
Python :: how to bubble search in python stack overflow 
Python :: run django using nssm 
Python :: cv2 warpaffine rotate 
Python :: how to code a jumping function in python 
Python :: entry point not found python.exe 
Python :: show all of a truncated dataframe jupyter" 
Python :: pandas exploring dataframe 
Python :: input character in python like getchar in c 
Python :: pyspark imputer 
Python :: remove exif from image 
Python :: python glob wildcard filename 
Python :: python callables 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =