Novice help, socket unable to create socket

Source: Internet
Author: User
Tags php error
Warning:socket_create (): Unable to create socket [94]: Socket type not supported in/web/xxx/apicookie.php on line 16
Warning:socket_connect () expects parameter 1 to BES resource, boolean given in/web/xxx/apicookie.php on line 28


This is the PHP error I was prompted when I used the function to create the socket!
$socket = Socket_create (AF_INET,0,SOL_TCP);
$result = @socket_connect ($socket, $address, $service _port);

The rest of the variables are not posted!
The code is not wrong! My testing on other servers is normal!

The error is a Linux vps!. I use the domestic AMH panel! The site you created!
The sockets extension is already open!
PHPINFO also saw that it did turn on!



What the hell is the reason? I searched the internet Baidu is no result!
To Google foreign posts that the firewall is blocked! And then I'm going to shut down the firewall! It's still not going to be tested!
I wonder if it's a matter of authority?


Reply to discussion (solution)

Take a good look at the manual, the second parameter is the type. is one of the following:
Sock_stream,sock_dgram,sock_seqpacket,sock_raw,sock_rdm
Yours is 0.

Socket_create (AF_INET,SOCK_STREAM,SOL_TCP)

Socket_create (AF_INET,SOCK_STREAM,SOL_TCP)
Yes, well, it did. Socket_create (AF_INET,SOCK_STREAM,SOL_TCP) passed the
But Socket_connect ($socket, $address, $service _port); It didn't pass.
Warning:socket_connect (): Unable to connect [111]: Connection refused in/web/xxx/apicookie.php on line 28

Solved the problem, thank you.


Socket_create (AF_INET,SOCK_STREAM,SOL_TCP)
Yes, well, it did. Socket_create (AF_INET,SOCK_STREAM,SOL_TCP) passed the
But Socket_connect ($socket, $address, $service _port); It didn't pass.
Warning:socket_connect (): Unable to connect [111]: Connection refused in/web/xxx/apicookie.php on line 28




Socket_create (AF_INET,SOCK_STREAM,SOL_TCP)
Yes, well, it did. Socket_create (AF_INET,SOCK_STREAM,SOL_TCP) passed the
But Socket_connect ($socket, $address, $service _port); It didn't pass.
Warning:socket_connect (): Unable to connect [111]: Connection refused in/web/xxx/apicookie.php on line 28



What's the deal, man?

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.