Results 1 to 8 of 8
  1. #1

    Creating a socket in PHP

    I am trying to open as many sockets I can against my mail server to test if it is prown to attack.

    I have tried to create 2000 sockets, but I can't seem to get it working and wondering if anyone knows whats going on?

    PHP Code:
    <?php
        $counter 
    0;
        
    createsocket:
        
    $socket socket_create(AF_INETSOCK_RAWtcp);
        
    socket_connect($socket"10.0.0.4"25);
        
    $counter++;
        if (
    $counter != 2000) {
            goto 
    createsocket;
        }
        
    sleep(240);
        
    socket_close($socket);
    ?>

  2. #2
    Join Date
    Mar 2010
    Location
    Upstate New York
    Posts
    1,452
    What is the PHP script doing that's telling you it's not working?
    John Rasri
    Private Label Live Chat Provider For Resellers
    GotLiveChat.com
    White Label/Brand-able live chat software solutions

  3. #3
    Join Date
    Jul 2009
    Location
    UK
    Posts
    1,312
    Quote Originally Posted by Etnica View Post
    I am trying to open as many sockets I can against my mail server to test if it is prown to attack.

    I have tried to create 2000 sockets, but I can't seem to get it working and wondering if anyone knows whats going on?

    PHP Code:
    <?php
        $counter 
    0;
        
    createsocket:
        
    $socket socket_create(AF_INETSOCK_RAWtcp);
        
    socket_connect($socket"10.0.0.4"25);
        
    $counter++;
        if (
    $counter != 2000) {
            goto 
    createsocket;
        }
        
    sleep(240);
        
    socket_close($socket);
    ?>


    Use a while loop?

    PHP Code:
    <?php
    while ($i <= 2000) {
        
    $i++;

    createsocket:
        
    $socket socket_create(AF_INETSOCK_RAWtcp);
        
    socket_connect($socket"10.0.0.4"25);

    }

        
    sleep(240);
        
    socket_close($socket);



        
    ?>
    Or along those lines..
    Live Chat Support Software for your Business website - IMsupporting.com

  4. #4
    If you are running linux, which I presume you are then run the following command
    sysctl -a | grep somaxconn
    This will tell you the highest amount of sockets that can be open at the same time. By default your system is most likely 128.
    Alert-Host.com - Web Hosting
    Contact: support@alert-host.com
    High quality web hosting.

  5. #5
    Quote Originally Posted by gotlivechat View Post
    What is the PHP script doing that's telling you it's not working?
    Its not telling me anything. I can see that it is opening a single connection, closing it, then opening the next.
    I am trying to have the connections all open at the same time.


    Quote Originally Posted by lynxus View Post
    Use a while loop?

    PHP Code:
    <?php
    while ($i <= 2000) {
        
    $i++;

    createsocket:
        
    $socket socket_create(AF_INETSOCK_RAWtcp);
        
    socket_connect($socket"10.0.0.4"25);

    }

        
    sleep(240);
        
    socket_close($socket);



        
    ?>
    Or along those lines..
    I will try this and report back.

  6. #6
    Join Date
    Jul 2009
    Location
    UK
    Posts
    1,312
    How about this:


    PHP Code:


    <?php

    $num 
    "0";

    while (
    $num <= "2000") {

    $num++;

    $fp fsockopen("10.0.0.4"25$errno$errstr30);
    if (!
    $fp) {
        echo 
    "$errstr ($errno)<br />\n";
    } else {
    echo 
    "Connected $num";

    }

    }
    ?>
    Live Chat Support Software for your Business website - IMsupporting.com

  7. #7
    Join Date
    Jul 2004
    Location
    London, UK
    Posts
    177
    RAW sockets on *any* OS require root/admin user. http://linux.die.net/man/7/raw

    Guessing that might be your issue. Also don't use goto, bad.

    You may also have a file descriptor issue with that many connections.

  8. #8
    Join Date
    Feb 2012
    Posts
    54
    how about install nodejs and solve your problems

Similar Threads

  1. Virtuozzo : getpeername error 88 (Socket operation on non-socket)
    By CrownS in forum Hosting Security and Technology
    Replies: 2
    Last Post: 06-22-2009, 01:22 PM
  2. Will a socket 478 P4 2.8Ghz HT fit into a socket 775 motherboard?
    By Shin Asuka in forum Computers and Peripherals
    Replies: 4
    Last Post: 11-21-2007, 04:28 AM
  3. Can't write to data socket. Socket error = #10054.
    By MartynD in forum Hosting Security and Technology
    Replies: 1
    Last Post: 10-02-2007, 03:25 AM
  4. need php developer familier with php socket operations
    By bclem in forum Employment / Job Offers
    Replies: 2
    Last Post: 09-28-2004, 06:34 PM
  5. tomcat, ssl, java, and creating a secure socket
    By brat_dan in forum Hosting Security and Technology
    Replies: 1
    Last Post: 07-23-2004, 12:14 AM

Posting Permissions

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