hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : Creating a socket in PHP
Reply

Forum Jump

Creating a socket in PHP

Reply Post New Thread In Programming Discussion Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 03-21-2012, 04:26 AM
Etnica Etnica is offline
New Member
 
Join Date: Mar 2012
Posts: 2

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);
?>



Sponsored Links
  #2  
Old 03-21-2012, 11:43 AM
gotlivechat gotlivechat is offline
Web Hosting Master
 
Join Date: Mar 2010
Location: Upstate New York
Posts: 1,091
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  
Old 03-21-2012, 11:54 AM
lynxus lynxus is offline
Lord of live chats
 
Join Date: Jul 2009
Location: UK
Posts: 1,263
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 software -> IMsupporting.com
Increase Sales Today - 100% No Strings Free Trial

Sponsored Links
  #4  
Old 03-21-2012, 12:17 PM
AH-Dan AH-Dan is offline
Newbie
 
Join Date: Oct 2011
Posts: 27
If you are running linux, which I presume you are then run the following command
Quote:
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  
Old 03-22-2012, 06:51 AM
Etnica Etnica is offline
New Member
 
Join Date: Mar 2012
Posts: 2
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  
Old 03-22-2012, 07:23 AM
lynxus lynxus is offline
Lord of live chats
 
Join Date: Jul 2009
Location: UK
Posts: 1,263
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 software -> IMsupporting.com
Increase Sales Today - 100% No Strings Free Trial

  #7  
Old 03-30-2012, 10:15 PM
streaky streaky is offline
WHT Addict
 
Join Date: Jul 2004
Location: London, UK
Posts: 163
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.

__________________
My Twitter

  #8  
Old 03-31-2012, 08:31 PM
Sinisa Sinisa is offline
Junior Guru Wannabe
 
Join Date: Feb 2012
Posts: 54
how about install nodejs and solve your problems

Reply

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

Related posts from TheWhir.com
Title Type Date Posted
Cisco to Invest $1 Billion in Global Cloud Network to Accelerate the Internet Of Things Web Hosting News 2014-03-24 12:03:24
Veloxsites Listing 2014-04-19 04:30:53
DreamHost CEO Talks Company Culture in NYT Interview Blog 2013-09-27 12:56:01
DEMO VIDEO: Idera Continuous Data Protection (Part 2) Whir Tv 2013-10-05 03:57:27
Prolexic Reports Key Holes in Popular DDoS Attack Tool Dirt Jumper Web Hosting News 2012-08-14 14:48:14


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?