473,406 Members | 2,371 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Problem socket connection in Unix

I'm moving a site from a Windows machine to the online environment (Unix) both running PHP5. But have a problem to get my data properly posted on the Unix machine.

On the unix machine my Content-Length of the post is 20 bytes less. I have put the 2 POST next to each other and they are the same.

Hereby the code that works fine on the Windows machine


[HTML]$body = 'theData';
$boundary = "---------------------".substr(md5(rand(0,32000)),0,10);
$host = theHost;
$port = "8080";
$path = PathToScript;

$data ='--'.$boundary.'
Content-Disposition: form-data; name="theXML"

'.$body.'
--'.$boundary.'--

';
$thepost = 'POST '.$path.' HTTP/1.0
Content-Type: multipart/form-data; boundary='.$boundary.'
Host: '.$host.':8080
Content-Length: '.strlen($data).'

'.$data;

$res = "";
$fsp = fsockopen($host, $port, $errno, $errstr, 30);
if($fsp) {
fputs($fsp, $thepost);

while(!feof($fsp)) {
$res .= fgets($fsp, 128);
}
fclose($fsp);
return $res;
}
else {
return "Error: " . $errstr;
}[/HTML]

But when I run the code on the unix machine the POST fails

Hereby the actual POST

win

[HTML]POST /Onlchk HTTP/1.0
Content-Type: multipart/form-data; boundary=---------------------dcf9082a17
Host: thehost:8080
Content-Length: 495
Connection: close

-----------------------dcf9082a17
Content-Disposition: form-data; name="theXML"

<OnlineCheck>
<Header>
<BuyerAccountId>ID</BuyerAccountId>
<AuthCode>CODE</AuthCode>
<Type>QUICK</Type>
</Header>
<Item line="1">
<ManufacturerItemIdentifier></ManufacturerItemIdentifier>
<ResellerItemIdentifier/>
<DistributorItemIdentifier>1335085</DistributorItemIdentifier>
<Quantity>1</Quantity>
</Item>
</OnlineCheck>
-----------------------dcf9082a17--[/HTML]



UNIX

[HTML]POST /Onlchk HTTP/1.0
Content-Type: multipart/form-data; boundary=---------------------c7bc77c261
Host: thehost:8080
Content-Length: 477
Connection: close

-----------------------c7bc77c261
Content-Disposition: form-data; name="theXML"

<OnlineCheck>
<Header>
<BuyerAccountId>ID</BuyerAccountId>
<AuthCode>CODE</AuthCode>
<Type>QUICK</Type>
</Header>
<Item line="1">
<ManufacturerItemIdentifier></ManufacturerItemIdentifier>
<ResellerItemIdentifier/>
<DistributorItemIdentifier>1335085</DistributorItemIdentifier>
<Quantity>1</Quantity>
</Item>
</OnlineCheck>
-----------------------c7bc77c261--[/HTML]



Anyone an idea ?
Sep 17 '07 #1
0 1107

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: adurbed | last post by:
Hi to everybody. First, let mi apologize if I'm doing a newbe question: I'm not a PHP programmer, but I have to solve a problem located in a PHP web page. Thanks in advance if you try to help...
2
by: Li Ma | last post by:
Just want to share my experience on XML-RPC. We were working on a messaging middleware. We were using XML-RPC as communication protocol amoing client apps and server. Client could be written by...
11
by: zaebos | last post by:
hi, i have this code which is part of a main program, to email from within the program a log file: int MailIt (char *mailserver, char *emailto, char *emailfrom, char *emailsubject, char...
0
by: Suresh | last post by:
Hi Guys I have Db2 server installed on remote server. i am connecting to that remote server by using VPN. I want to connect that remote DB2 server instance using my local machine DB2...
5
by: Suresh | last post by:
Hi Guys I have Db2 server installed on remote server. i am connecting to that remote server by using VPN. I want to connect that remote DB2 server instance using my local machine DB2...
2
by: Mirko Vogt | last post by:
Hey, it seems that the socket-module behaves differently on unix / windows when a timeout is set. Here an example: # test.py import socket...
0
by: Gabriel Genellina | last post by:
En Wed, 09 Jul 2008 15:02:56 -0300, Mirko Vogt <lists@nanl.deescribi�: Which Python version? Which Windows version? I've tried 2.3.4, 2.4.4, 2.5.1 and 3.0a4, all on WinXP SP2, and in all...
0
by: Mirko Vogt | last post by:
Gabriel Genellina wrote: Hey, this is strange. Linux: $ python --version Python 2.5.2 $ Windows:
3
by: TsanChung | last post by:
I want to make a java TCP socket client to communicate with a TCP server socket on linux. Are there some sample C unix server and java client socket programs available? The Richard Stevens'...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.