/    Sign up×
Community /Pin to ProfileBookmark

PHP Interacting w/ 3rd party programs

I know you can use PHP to call shell programs but is it possible to use php to call a custom program (say a daemon service I write in c) through tcp/ip? If this is possible what php functions can I use to do this? Are there any tutorials out there that cover this?

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@shimonJun 23.2004 — Hmm yeah you should be able to do that relatively easily - I'm not sure about tutorials but there's some examples in the manual.

If you have your daemon humming away listening on some port or other you should be able to use [URL=http://www.php.net/fsockopen]fsockopen()[/URL] to connect to it and then the various fputs(), fgets() functions to exchange data with the daemon.

You'll have to implement the actual interaction/top-level protocol yourself, of course. The nicest thing to do would be to create a PHP class that wraps it all up and provides a clean API to your main PHP code.

Good luck ?
×

Success!

Help @ilbonparaurti spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...