Jump to content


Photo

Socket issue on host server, but not local :(


  • Please log in to reply
6 replies to this topic

#1 sk93

sk93
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 03 August 2006 - 11:06 PM

Hi,

Firstly, this is my first post here - so please be gentle :)

OK - I've got a lump of PHP that I am trying to use to communicate with a remote server.
When I run the code my one of my local linux servers (ie, on the same LAN as my desktop pc, but NOT the remote server), the code works perfectly and I get no errors at all.

However, when I upload my code to my webserver, the code fails with the following warning:

Warning: socket_sendto() unable to write to socket [1]: Operation not permitted

The code is as follows:

    $socket=socket_create(AF_INET,SOCK_DGRAM,SOL_UDP);
    socket_set_option($socket,SOL_SOCKET,SO_RCVTIMEO,array('sec'=>$this->timeout,'usec'=>0));
    if (!$socket) 
	{
		return;
	}
	$packet=null; 
	$this->packets=null;
	
    if (!socket_sendto($socket,$transmission,strlen($transmission),0x100,$ip,$port))
	{
		return;
	}



Not sure if it's relevent, but here's the contents of phpinfo from my server and then the webserver:

My server:
PHP Version 4.3.7 

Configure Command  './configure' '--prefix=/usr' '--host=i686-pc-linux-gnu' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--datadir=/usr/share' 
'--sysconfdir=/etc' '--localstatedir=/var/lib' '--with-apxs2=/usr/sbin/apxs2' '--with-ndbm=/usr' '--with-db4=/usr' '--with-mcrypt=/usr' '--with-mhash=/usr' 
'--without-interbase' '--without-ming' '--without-swf' '--without-sybase' '--with-gdbm=/usr' '--without-fdftk' '--with-java=/opt/blackdown-jdk-1.4.1' 
'--without-mcal' '--without-unixODBC' '--without-pgsql' '--without-snmp' '--with-xpm-dir=/usr/X11R6' '--without-gmp' '--without-mssql' '--with-pdflib=/usr' 
'--without-gd' '--with-png=/usr' '--with-png-dir=/usr' '--with-jpeg=/usr' '--with-jpeg-dir=/usr' '--enable-exif' '--with-tiff=/usr' '--with-tiff-dir=/usr' 
'--with-mysql=/usr' '--with-mysql-sock=/var/run/mysqld/mysqld.sock' '--with-freetype-dir=/usr' '--with-ttf=/usr' '--with-t1lib=/usr' '--with-gettext' 
'--with-qtdom=/usr/qt/3' '--with-pspell=/usr' '--with-openssl=/usr' '--without-imap' '--without-ldap' '--with-dom=/usr' '--with-dom-xslt=/usr' 
'--with-dom-exslt=/usr' '--without-kerberos' '--with-pam' '--disable-memory-limit' '--disable-ipv6' '--without-yaz' '--without-curl' '--enable-dbx' 
'--with-zlib=/usr' '--with-zlib-dir=/usr' '--with-sablot=/usr' '--enable-xslt' '--with-xslt-sablot' '--with-xmlrpc' '--enable-wddx' '--with-xml' '--enable-mbstring=all' 
'--enable-mbregex' '--with-bz2=/usr' '--with-crack=/usr' '--with-cdb' '--enable-pcntl' '--enable-bcmath' '--enable-calendar' '--enable-dbase' '--enable-filepro' 
'--enable-ftp' '--with-mime-magic=/usr/share/misc/file/magic.mime' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvipc' '--with-iconv' 
'--enable-shmop' '--enable-dio' '--enable-yp' '--without-ncurses' '--without-readline' '--enable-inline-optimization' '--enable-track-vars' '--enable-trans-sid' 
'--enable-versioning' '--with-config-file-path=/etc/php/apache2-php4' '--without-pear'  


sockets
Sockets Support  enabled  

The failing webserver:
PHP Version 4.3.10 

Configure Command  './configure' 'i386-redhat-linux' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' 
'--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/usr/com' 
'--mandir=/usr/share/man' '--infodir=/usr/share/info' '--prefix=/usr' '--with-config-file-path=/etc' '--disable-debug' '--enable-pic' '--disable-rpath' 
'--enable-inline-optimization' '--with-bz2' '--with-db3' '--with-curl' '--with-dom=/usr' '--with-exec-dir=/usr/bin' '--with-freetype-dir=/usr' 
'--with-png-dir=/usr' '--with-gd' '--enable-gd-native-ttf' '--with-ttf' '--with-gdbm' '--with-gettext' '--with-ncurses' '--with-gmp' '--with-iconv' 
'--with-jpeg-dir=/usr' '--with-mm' '--with-openssl' '--with-png' '--with-pspell' '--with-regex=system' '--with-xml' '--with-expat-dir=/usr' '--with-zlib' 
'--with-layout=GNU' '--enable-bcmath' '--enable-debugger' '--enable-exif' '--enable-ftp' '--enable-magic-quotes' '--enable-safe-mode' '--enable-sockets' 
'--enable-sysvsem' '--enable-sysvshm' '--enable-discard-path' '--enable-track-vars' '--enable-trans-sid' '--enable-yp' '--enable-wddx' '--without-oci8' 
'--with-imap=shared' '--with-imap-ssl' '--with-kerberos=/usr/kerberos' '--with-ldap=shared' '--with-mysql=shared,/usr' '--with-pgsql=shared' 
'--with-snmp=shared,/usr' '--with-snmp=shared' '--enable-ucd-snmp-hack' '--with-unixODBC=shared' '--enable-memory-limit' '--enable-bcmath' 
'--enable-shmop' '--enable-versioning' '--enable-calendar' '--enable-dbx' '--enable-dio' '--enable-mbstring' '--enable-mbstr-enc-trans' '--enable-cgi' 
'--enable-cli' '--disable-force-cgi-redirect'  


sockets
Sockets Support  enabled  

I have tried googling this and didn't get anything at all (no.. really!)
I also tried searching here a few times, but didn't find anything that I thought was related (but am willing to admit I am wrong!)

If anyone can help, I'd greatly appreciate it!

Cheers,
Sk93

#2 sk93

sk93
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 04 August 2006 - 08:24 AM

*bump* still can't work this one out :(

#3 sk93

sk93
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 04 August 2006 - 12:55 PM

*bump again * - sorry but I'm really stuck with this :(

#4 shoz

shoz
  • Staff Alumni
  • Advanced Member
  • 600 posts

Posted 04 August 2006 - 01:15 PM

It may be your firewall (an iptable rule) that's causing the problem. I was able to get the same error by blocking udp "connections".

#5 sk93

sk93
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 04 August 2006 - 01:29 PM

I am starting to think you may well be right!

I've converted the code to use a TCP socket rather than UDP and it connects (albeit that it then fails because the server is expecting a UDP connection rather than UDP!)....

I'm currently on the hold with the hosting company :/

thanks,
Sk93

#6 CTM

CTM
  • Members
  • PipPip
  • Member
  • 15 posts

Posted 04 August 2006 - 03:14 PM

shoz's probably right. Your webhost might prevent (out or in) UDP connections.

#7 sk93

sk93
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 04 August 2006 - 08:25 PM

they most certainly do  :(

it'd be nicer if this error message was a little bit more on point, but never-the-less

Thanks again for the answers!

Sk93




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users