Delphi For PHP Forums    


Go Back   Delphi-PHP Forums > Delphi4PHP NNTP Newsgroups > embarcadero.public.delphiphp.thirdpartytools
Forum Jump Register FAQ Members List Downloads Search Today's Posts Mark Forums Read

embarcadero.public.delphiphp.thirdpartytools This group is for all discussion about third-party components for Delphi for PHP. That includes marketing, creating, asking about, and pitching various third-party components.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 5th March 2009, 09:40
Glen Welch
Guest
 
Posts: n/a
Default Socket components

Hi,
I am very new to PHP though have delphi programming experience since Delphi
1.0. I have a few client /server applications written in delphi using indy
client & server components.
We are looking at providing web interfaces to some of these server apps and
thought that Delphi PHP would be the way to go.
To get started though we need to be able to connect to our server app using
a TCP?ip connection. Can anyone recommend a socket component that could do
this for us, ideally with some demos as our knowledge is about nil.

Thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 5th March 2009, 15:50
Jonathan Benedicto
Guest
 
Posts: n/a
Default Re: Socket components

Glen Welch wrote:
> Hi,
> I am very new to PHP though have delphi programming experience since
> Delphi
> 1.0. I have a few client /server applications written in delphi using
> indy
> client & server components.
> We are looking at providing web interfaces to some of these server apps
> and
> thought that Delphi PHP would be the way to go.
> To get started though we need to be able to connect to our server app
> using
> a TCP?ip connection. Can anyone recommend a socket component that could
> do
> this for us, ideally with some demos as our knowledge is about nil.


PHP already has easy to use TCP/IP connection abilities.

For example:
// Open a connection to www.example.com on port 80.
$fp = fsockopen("www.example.com", 80, $errno, $errstr, 30);
if( !$fp )
{
// If connection fails, throw Exception.
throw new Exception( "Failed to connect to www.example.com, $errstr
($errno)" );
}
else
{
// Create a HTTP GET request
$out = "GET / HTTP/1.1\r\n";
$out .= "Host: www.example.com\r\n";
$out .= "Connection: Close\r\n\r\n";

// Send it to the socket.
fwrite($fp, $out);

// While there is data to be read, and the connection is open, keep
reading.
while( !feof( $fp ) )
{
echo fgets($fp, 128);
}

// Close the connection handle.
fclose( $fp );
}

Jon
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT +1. The time now is 05:06.




Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0 ©2009, Crawlability, Inc.
Copyright © 2004 - 2009, G&J Solutions Ltd. All Rights Reserved. terms of use