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
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
Web Hosting Master
 
Join Date: Mar 2010
Location: Upstate New York
Posts: 1,264
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
Lord of live chats
 
Join Date: Jul 2009
Location: UK
Posts: 1,294
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

Sponsored Links
  #4  
Old
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
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
Lord of live chats
 
Join Date: Jul 2009
Location: UK
Posts: 1,294
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  
Old
WHT Addict
 
Join Date: Jul 2004
Location: London, UK
Posts: 162
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
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
Cloud Computing Will Be Used by 78 Percent of Small Businesses in 2020 Web Hosting News 2014-08-15 12:48:46
IBM Launches New SoftLayer Partner Program Initiatives to Help Partners Drive Cloud Demand Web Hosting News 2014-04-30 18:21:58
Cisco to Invest $1 Billion in Global Cloud Network to Accelerate the Internet Of Things Web Hosting News 2014-03-24 12:03:24
Hackers Find Cloud Account Credentials on GitHub Leading to 72-Hour Cryptocurrency Mining Spree Web Hosting News 2014-01-17 12:13:36
DreamHost CEO Talks Company Culture in NYT Interview Blog 2013-09-27 12:56:01


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?
WHT Host Brief Email:

We respect your privacy. We will never sell, rent, or give away your address to any outside party, ever.

Advertisement:
Web Hosting News:
WHT Membership
WHT Membership



 

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?