LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-10-2012, 03:51 PM   #1
ihopeto
LQ Newbie
 
Registered: Jan 2006
Posts: 19

Rep: Reputation: 0
PHP opening socket to write data


Centos with Apache server.

Php version 4.3

wanting to send data out a socket for reading by another computer Program (windows).

I read the data from a third computer (windows). On the Centos server box I manipulate the data and want to send out to be read by a program on a windows machine. My problem is that I cannot open a socket to write to.

PHP Code:
$fpfsockopen("192.168.1.102",30003,$errno,$errstr,30); 
error is -

Warning: fsockopen(): unable to connect to 192.168.1.102:30003 in reroute.php on line 48


I have disabled the firewall, error the same.

192....102 is the centos server.

replacing 192.168.1.102 with localhost same error.

The php script is being run with root.

thanks for your help.
 
Old 01-10-2012, 04:04 PM   #2
Doc CPU
Senior Member
 
Registered: Jun 2011
Location: Stuttgart, Germany
Distribution: Mint, Debian, Gentoo, Win 2k/XP
Posts: 1,099

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
Hi there,

Quote:
Originally Posted by ihopeto View Post
Warning: fsockopen(): unable to connect to 192.168.1.102:30003 in reroute.php on line 48
that means, either there is no service listening on port 30003 of IP 192.168.1.102, or if it is, the communication between that host and the one which the script is running on is blocked.

[X] Doc CPU
 
Old 01-10-2012, 04:15 PM   #3
ihopeto
LQ Newbie
 
Registered: Jan 2006
Posts: 19

Original Poster
Rep: Reputation: 0
Thanks Doc,

Is there a way to send data to a port so it can be read by a third party software that listens on a specific port?
 
Old 01-10-2012, 04:55 PM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,700

Rep: Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895
Quote:
192....102 is the centos server.
Typo? Should be the address of the windows PC. Using localhost is the same as sending data to the CentOS PC and not the windows PC.

Make sure the windows PC firewall allows connections on the desired port.

You can test your program on the CentOS server by using the netcat (nc) command in a second console window.
nc -lp 30003
Then when you run your program you should see the data. Use localhost or the IP address of the CentOS server.

Is the server on the windows PC expecting TCP or UDP?
 
Old 01-10-2012, 06:05 PM   #5
ihopeto
LQ Newbie
 
Registered: Jan 2006
Posts: 19

Original Poster
Rep: Reputation: 0
I need to clarify.

Computer 1- windows - runs an application that sends data out its port 30003.

computer 2- centos linux with php, apache, and mysql. This is where the script is run. The script in question reads the data from computer 1, manipulates the data and sends it to a tcp port (at least thats what I am trying to do).

computer 3- windows - runs an application that reads the new data and forwards the data to a database over the internet.

computer 2 ip is 192.168.1.102. Thus the error

Warning: fsockopen(): unable to connect to 192.168.1.102:30003 in reroute.php on line 48

----
Hope that clarifies.

thanks for helping.

Last edited by ihopeto; 01-10-2012 at 06:20 PM.
 
Old 01-10-2012, 08:09 PM   #6
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,700

Rep: Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895
As already stated there doesn't seem to be any service running on port 30003 of the CentOS computer. The address should be one of the windows boxes depending on if you are reading or writing.
 
Old 01-10-2012, 09:04 PM   #7
ihopeto
LQ Newbie
 
Registered: Jan 2006
Posts: 19

Original Poster
Rep: Reputation: 0
Can I create a service that will send the data out of the centos box on port 30003

with a php script?

an example would be most helpful.
 
Old 01-11-2012, 01:39 PM   #8
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,700

Rep: Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895
Yes. This might help.
http://devzone.zend.com/209/writing-...ervers-in-php/
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
read and write binary data from socket sdas7 Linux - Networking 2 05-24-2009 01:09 PM
write and read socket lrios Programming 1 05-01-2008 01:19 PM
cannot read data at server socket, though client socket sends it jacques83 Linux - Networking 0 11-15-2005 01:58 PM
MySQL/PHP/Horde "Failed to write session data" Big Money Linux - Software 0 11-23-2004 01:33 PM
write() a variable(integer) to socket? koyi Programming 6 07-08-2004 09:42 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:46 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration