Jump to content

how to use PHP to POST to listening IP/port


tate_etc

Recommended Posts

i can post XML data to a website via cURL

 

can i use cURL to post XML to a local TCP IP/port?

 

when i simply switch the server from server website.com port 443 to server 127.0.0.1 port 2000, the script times out (port 80 works, of course)

 

all programs are installed on same PC. i have two programs that currently post XML data via java socket classes, so i know the ip/port is open

 

does anyone have any suggestions?

  • 4 weeks later...

So I finally have gotten a connection between server/client via cURL. The problem was that I wasn't sending a string to the server. I mostly work with web-based programs & they usually error out differently, so I was surprised when I discovered that that was the problem...

 

Now, I would like to be able to send data to the server, but cURL appends header info to the string like this:

 

POST / HTTP/1.1

Host: ausrcsht02:2000

Accept: */*

Content-Length: 51

Content-Type: application/x-www-form-urlencoded

 

0,"004"1,"Assign Tracking Number"498,""499,"1"99,""

 

How do I post just the raw data? Here is my code:

 

<?

$ch = curl_init();

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

curl_setopt($ch, CURLOPT_HEADER, 0);

curl_setopt($ch, CURLOPT_POST, 1);

curl_setopt($ch, CURLOPT_POSTFIELDS, '0,"004"1,"Assign Tracking Number"498,""499,"1"99,""');

curl_setopt($ch, CURLOPT_TIMEOUT, 10);

curl_setopt($ch, CURLOPT_URL, "localhost:2000");

$contents = curl_exec($ch);

curl_close($ch);

echo $contents;

?>

 

Thanks in advance!!!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.