no buffer space available error

sebastien s.thuriez at laposte.net
Thu May 9 08:41:44 EDT 2002


Hi,

This is the code that I used. After this there is the log file with
all the connexions...


import httplib
import select
import sys, string, os
import socket
from ftplib import *
import time
import thread
from pprint import pprint
import threading
import timeoutsocket

timeoutsocket.setDefaultSocketTimeout(5)
BUFSIZE = 1024
FTP_PORT = 21
FTP_DATA_PORT = FTP_PORT - 1
FTP_DATA_PORT = FTP_DATA_PORT + 50000

ftp_existe=[]
debug=[]
error_control=[]
no_buffer_space_available=[]
warning=[]
global warning
global timeout

def control(hostname):

    global ftp_existe

    reponse='non'
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.setblocking(0)
    ensemble=[]
    ensemble.append(hostname)
    ensemble.append(FTP_PORT)

    print "connect : ",hostname
    try :
        s.connect((hostname,FTP_PORT))
    except socket.error, why :
        debug.append((hostname,why[1]))
        if why[1] <> "The socket operation could not complete without
blocking":
            print 'cannot connect...',hostname, "why = ",why[1]
            
    potential_readers=[]
    potential_readers.append(s.fileno())
    potential_writers=[]
    potential_writers.append(s.fileno())
    potential_errs=[]
    time_out=2
    #print 'juste avant le selectselect'
    ready_to_read, ready_to_write, in_error =
select.select(potential_readers, potential_writers,
potential_errs,time_out)
    if len(ready_to_read)<> 0 or len(ready_to_write) <> 0 :
        print 'control : response from : ', hostname, " on port
",FTP_PORT
        reponse='oui'
        if hostname in ftp_existe:
            print "allreday exits"
            pass
        else:
            debug.append((hostname,"ftp server"))
            ftp_existe.append(hostname)
    try:
        s.close()
    except:
        pass
            
    return reponse


def maine():

    global ftp_existe, identifiant_thread
    global timeout
    global warning

    ftp_existe=[]
    max_thread=10
    
    FTP_port=21
    number_thread=1
    for indice in range(1,255): #to scan the network
        adresse="192.168.15."+str(indice)
        if number_thread>max_thread:
            print "question_ftp_threaded :  number thread > max thread
:sleeping"
            time.sleep(2)
            number_thread=0
        else:
            number_thread=number_thread+1
        try :
            thread.start_new_thread(control,(adresse,))
        except:
            print "pas de lancement thread "

    print "ftp server found :", ftp_existe

    file=open ("c:\debug.txt","w")
    for hostname, error_message in debug:
        file.write(hostname+ " "+error_message+"\n")
    file.close()
    
    return

def main() :    

    debug=[]
    ftp_existe=[]
    maine()
    print "fin"


main()    


The debug file that was generated.


192.168.15.2 The socket operation could not complete without blocking
192.168.15.7 The socket operation could not complete without blocking
192.168.15.6 The socket operation could not complete without blocking
192.168.15.5 The socket operation could not complete without blocking
192.168.15.4 The socket operation could not complete without blocking
192.168.15.3 The socket operation could not complete without blocking
192.168.15.1 The socket operation could not complete without blocking
192.168.15.8 The socket operation could not complete without blocking
192.168.15.9 The socket operation could not complete without blocking
192.168.15.10 The socket operation could not complete without blocking
192.168.15.11 The socket operation could not complete without blocking
192.168.15.12 The socket operation could not complete without blocking
192.168.15.13 The socket operation could not complete without blocking
192.168.15.14 The socket operation could not complete without blocking
192.168.15.15 The socket operation could not complete without blocking
192.168.15.16 The socket operation could not complete without blocking
192.168.15.17 The socket operation could not complete without blocking
192.168.15.18 The socket operation could not complete without blocking
192.168.15.19 The socket operation could not complete without blocking
192.168.15.20 The socket operation could not complete without blocking
192.168.15.22 The socket operation could not complete without blocking
192.168.15.21 The socket operation could not complete without blocking
192.168.15.24 The socket operation could not complete without blocking
192.168.15.25 The socket operation could not complete without blocking
192.168.15.23 The socket operation could not complete without blocking
192.168.15.26 The socket operation could not complete without blocking
192.168.15.27 The socket operation could not complete without blocking
192.168.15.28 The socket operation could not complete without blocking
192.168.15.30 The socket operation could not complete without blocking
192.168.15.29 The socket operation could not complete without blocking
192.168.15.31 The socket operation could not complete without blocking
192.168.15.32 The socket operation could not complete without blocking
192.168.15.33 The socket operation could not complete without blocking
192.168.15.34 The socket operation could not complete without blocking
192.168.15.36 The socket operation could not complete without blocking
192.168.15.37 The socket operation could not complete without blocking
192.168.15.38 The socket operation could not complete without blocking
192.168.15.39 The socket operation could not complete without blocking
192.168.15.40 The socket operation could not complete without blocking
192.168.15.41 The socket operation could not complete without blocking
192.168.15.43 The socket operation could not complete without blocking
192.168.15.42 The socket operation could not complete without blocking
192.168.15.35 The socket operation could not complete without blocking
192.168.15.44 The socket operation could not complete without blocking
192.168.15.45 The socket operation could not complete without blocking
192.168.15.46 The socket operation could not complete without blocking
192.168.15.48 The socket operation could not complete without blocking
192.168.15.49 The socket operation could not complete without blocking
192.168.15.47 The socket operation could not complete without blocking
192.168.15.50 The socket operation could not complete without blocking
192.168.15.51 The socket operation could not complete without blocking
192.168.15.52 The socket operation could not complete without blocking
192.168.15.53 The socket operation could not complete without blocking
192.168.15.54 The socket operation could not complete without blocking
192.168.15.55 The socket operation could not complete without blocking
192.168.15.56 The socket operation could not complete without blocking
192.168.15.57 The socket operation could not complete without blocking
192.168.15.58 The socket operation could not complete without blocking
192.168.15.59 The socket operation could not complete without blocking
192.168.15.60 The socket operation could not complete without blocking
192.168.15.61 The socket operation could not complete without blocking
192.168.15.62 The socket operation could not complete without blocking
192.168.15.63 The socket operation could not complete without blocking
192.168.15.64 The socket operation could not complete without blocking
192.168.15.65 The socket operation could not complete without blocking
192.168.15.66 The socket operation could not complete without blocking
192.168.15.67 The socket operation could not complete without blocking
192.168.15.68 The socket operation could not complete without blocking
192.168.15.69 The socket operation could not complete without blocking
192.168.15.70 The socket operation could not complete without blocking
192.168.15.72 The socket operation could not complete without blocking
192.168.15.73 The socket operation could not complete without blocking
192.168.15.71 The socket operation could not complete without blocking
192.168.15.75 The socket operation could not complete without blocking
192.168.15.74 The socket operation could not complete without blocking
192.168.15.76 The socket operation could not complete without blocking
192.168.15.77 The socket operation could not complete without blocking
192.168.15.78 The socket operation could not complete without blocking
192.168.15.79 The socket operation could not complete without blocking
192.168.15.81 The socket operation could not complete without blocking
192.168.15.80 The socket operation could not complete without blocking
192.168.15.82 The socket operation could not complete without blocking
192.168.15.84 The socket operation could not complete without blocking
192.168.15.83 The socket operation could not complete without blocking
192.168.15.85 The socket operation could not complete without blocking
192.168.15.86 The socket operation could not complete without blocking
192.168.15.87 The socket operation could not complete without blocking
192.168.15.88 The socket operation could not complete without blocking
192.168.15.89 The socket operation could not complete without blocking
192.168.15.90 The socket operation could not complete without blocking
192.168.15.91 The socket operation could not complete without blocking
192.168.15.92 The socket operation could not complete without blocking
192.168.15.93 The socket operation could not complete without blocking
192.168.15.94 The socket operation could not complete without blocking
192.168.15.102 The socket operation could not complete without
blocking
192.168.15.95 The socket operation could not complete without blocking
192.168.15.103 The socket operation could not complete without
blocking
192.168.15.104 The socket operation could not complete without
blocking
192.168.15.105 The socket operation could not complete without
blocking
192.168.15.106 The socket operation could not complete without
blocking
192.168.15.96 The socket operation could not complete without blocking
192.168.15.97 The socket operation could not complete without blocking
192.168.15.98 The socket operation could not complete without blocking
192.168.15.99 The socket operation could not complete without blocking
192.168.15.100 The socket operation could not complete without
blocking
192.168.15.101 The socket operation could not complete without
blocking
192.168.15.102 ftp server
192.168.15.103 ftp server
192.168.15.105 ftp server
192.168.15.107 The socket operation could not complete without
blocking
192.168.15.108 The socket operation could not complete without
blocking
192.168.15.109 The socket operation could not complete without
blocking
192.168.15.110 The socket operation could not complete without
blocking
192.168.15.111 The socket operation could not complete without
blocking
192.168.15.112 The socket operation could not complete without
blocking
192.168.15.113 The socket operation could not complete without
blocking
192.168.15.115 No buffer space available
192.168.15.114 No buffer space available
192.168.15.116 No buffer space available
192.168.15.117 No buffer space available
192.168.15.118 No buffer space available
192.168.15.111 ftp server
192.168.15.107 ftp server
192.168.15.108 ftp server
192.168.15.120 The socket operation could not complete without
blocking
192.168.15.121 The socket operation could not complete without
blocking
192.168.15.119 The socket operation could not complete without
blocking
192.168.15.122 No buffer space available
192.168.15.123 No buffer space available
192.168.15.124 No buffer space available
192.168.15.125 No buffer space available
192.168.15.127 No buffer space available
192.168.15.126 No buffer space available
192.168.15.128 No buffer space available
192.168.15.129 No buffer space available
192.168.15.130 No buffer space available
192.168.15.132 No buffer space available
192.168.15.131 No buffer space available
192.168.15.133 No buffer space available
192.168.15.134 No buffer space available
192.168.15.135 No buffer space available
192.168.15.136 No buffer space available
192.168.15.137 No buffer space available
192.168.15.138 No buffer space available

and so on .....

Regards.
Sebastien






Michael Gilfix <mgilfix at eecs.tufts.edu> wrote in message news:<mailman.1020882313.2436.python-list at python.org>...
> Can you post some more code? I'm having a hard time figuring
> out just what your problem (what are you doing before) and can
> you post the trace?
> 
>               -- Mike
> 
> On Wed, May 08 @ 10:42, sebastien wrote:
> > Hi,
> > 
> > I am trying a program that scan all the machines in the network that are ftp server.
> > After about 50 to 100 scan, I get the message :
> > 
> > no buffer space available.
> > 
> > import timeoutsocket
> > timeoutsocket.setDefaultSocketTimeout(5)
> > BUFSIZE = 1024
> > FTP_PORT = 21
> > FTP_DATA_PORT = FTP_PORT - 1
> > FTP_DATA_PORT = FTP_DATA_PORT + 50000
> > 
> > s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> > s.setblocking(0)
> > 
> > try :
> >     s.connect((hostname,FTP_PORT))
> > except socket.error, why :
> >     print 'cannot connect...',why[1]
> > 
> > 
> > This is embedded in a function and I pass the hostname that I want to be tested.
> > 
> > 
> > What do I do wrong ? As I get the message can I flush the buffer ?
> > I am running python 2.1.1 on Windows Me and NT.
> > 
> > Regards,
> > Sebastien.
> > -- 
> > http://mail.python.org/mailman/listinfo/python-list
> `-> (s.thuriez)



More information about the Python-list mailing list