I just created a web application that uses sockets in my local server. Everything works. The problems start when I hosted my resources on a 1and1 shared server. I get the following fatal error
Fatal error: Call to undefined function socket_create ()
it is clear that the extension php_socket is not enabled. There's there a way to enable this extension by code?
In most cases, you cannot install or activate additional PHP modules on shared hosting.
Shared hosting has a very limited perimeter and strict security requirements. Most functions for program execution and networking will be disabled on most shared hosting offers. Shared hosting offers that let you do anything are very rare and priced accordingly.
Besides, installing or activating extensions at execution time is impossible since PHP version 5.3. See http://php.net/manual/en/function.dl.php
If you want to build advanced applications, shared hosting is not the right product choice. Look for virtual servers (which you can set up as you like) or even get a full dedicated server.
If you really want to press the matter, I recommend contacting your 1&1 customer service and ask for directions there. They may or may not be able to help you on to achieve your goal.