tate_etc Posted October 18, 2007 Share Posted October 18, 2007 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? Link to comment https://forums.phpfreaks.com/topic/73847-how-to-use-php-to-post-to-listening-ipport/ Share on other sites More sharing options...
derwert Posted October 21, 2007 Share Posted October 21, 2007 Make sure your web server is listening on 127.0.0.1, not all web servers listen on the loopback address. Some just listen on the public address(es) set in the configuration. You can check by using netstat -a Link to comment https://forums.phpfreaks.com/topic/73847-how-to-use-php-to-post-to-listening-ipport/#findComment-374659 Share on other sites More sharing options...
tate_etc Posted November 12, 2007 Author Share Posted November 12, 2007 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!!! Link to comment https://forums.phpfreaks.com/topic/73847-how-to-use-php-to-post-to-listening-ipport/#findComment-390233 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.