Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: forceing port connections

  1. #1
    Senior Member
    Join Date
    Jun 2003
    Posts
    101

    forceing port connections

    i do not want to get flamed for this because it might sound like i want to learn about DOS, which i do not

    but

    is there a way i can force multiple connections to a given port?

    this is to test my VNC server and web server
    like life, this is a test

  2. #2
    Senior Member
    Join Date
    Mar 2004
    Posts
    119
    Yeah, telnet to the port multiple times.

  3. #3
    Senior Member
    Join Date
    Jun 2003
    Posts
    101
    can i automate this or do i have to type in >: telnet xyz 5900 again and again?
    like life, this is a test

  4. #4
    Senior Member
    Join Date
    Jan 2003
    Posts
    3,915
    Originally posted here by yellowcat
    can i automate this or do i have to type in >: telnet xyz 5900 again and again?
    Wouldn't it be more fun to try this yourself or learn how to do it yourself??? What's the point in it if you don't learn anything?

    Regardless.. this can be done quite easily in python:

    Code:
    #!/usr/bin/env python
    
    
    import threading
    import socket
    import sys
    
    
    class threadedConnect ( threading.Thread ):
    
            def __init__ ( self, host, port, timeout ) :
    
                    self.host = host # host to connect to
                    self.port = port # port to connnect to
                    self.timeout = timeout # 0 for no timeout
                    threading.Thread.__init__ ( self )
    
            def run ( self ) :
    
                    self.sock = socket.socket ( socket.AF_INET, socket.SOCK_STREAM )
                    self.sock.settimeout( self.timeout )
                    self.sock.connect ( ( self.host, self.port ) )
                    print self.sock.recv( 1024 )
    
    
    #Init Variables
    
    host = sys.argv[ 1 ]
    port = int ( sys.argv[ 2 ] )
    timeout = int ( sys.argv [ 3 ] )
    connCount = int ( sys.argv [ 4 ] )
    
    
    for x in xrange ( connCount ) : #Number of connections to make
    
            threadedConnect( host, port, timeout).start()
    How do you run it... how does it work... what do you need... Well that's up to you... but there's a very simple script for you (Yes I realize I could have made it easier... but where's the fun in that)... Also I didn't incorporate any error checking... so you'll die on errors... but it'll still do what you want.

    Peace,
    HT

  5. #5
    Senior Member
    Join Date
    Jun 2003
    Posts
    101
    well i should now take up programming!!
    read a few books but they ALL start off with 'hello world' and do not get more exciting than that

    will give it a go

    cheers for the script
    like life, this is a test

  6. #6
    Senior Member
    Join Date
    Jun 2003
    Posts
    101
    well i have run it and yes there are errors!!
    no idea what IndexError means but having a look on web to see
    does not like the import socket line or host = sys.argv [1]
    like life, this is a test

  7. #7
    Just Another Geek
    Join Date
    Jul 2002
    Location
    Rotterdam, Netherlands
    Posts
    3,401
    Originally posted here by yellowcat
    well i should now take up programming!!
    read a few books but they ALL start off with 'hello world' and do not get more exciting than that
    You will need to learn how to walk before you're able to run
    Oliver's Law:
    Experience is something you don't get until just after you need it.

  8. #8
    Senior Member
    Join Date
    Jun 2003
    Posts
    101
    ok done some playing around with the code
    to no avail

    i changed this
    host = sys.argv[ 1 ]

    to this
    host = int ( sys.argv[ 1 ] )


    but that did not work
    and IndexError seems to be a universal type of error in many programming languages
    like life, this is a test

  9. #9
    Senior Member
    Join Date
    Jun 2003
    Posts
    101
    am i missing modules?
    i have tried several pre written scripts with
    import socket
    but non of them work.......
    like life, this is a test

  10. #10
    Senior Member
    Join Date
    Jan 2003
    Posts
    3,915
    Hey Hey

    If you've got Python, you've got everything you need to run the script and there are no changes that have to be made... it works perfectly the way it is.

    I'd suggest you go look up why sys.argv[] is used... That will be your clue...

    Peace,
    HT

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •