Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Send and Receive data thru TCP from Server!!

Status
Not open for further replies.

Forri

Programmer
Joined
Oct 29, 2003
Messages
479
Location
MT
Hi all

I'm trying to comunicate with a server thru TCP! this server is gateway for a bank! So i'm sending the gateway an ascii string and the server should send back a response with an eror or acceptance!

The problem is that when the user clicks the Send button the pages starts loading and sometimes its really fast and works flawlessly but other times its slow as if nothing happened so the clients press the send button again! this usually results in a double payment!

I'm not sure if the problem lies within the way i'm sending and receiing or else rom the payment people!

I'm using this method to send and receive the data:

Code:
$fp = fsockopen ("xxx.xxx.xxx.xxx",xxxx, $errno, $errstr, 30);
if (!$fp) {
    echo "$errstr ($errno)<br>\n";
} else {
    fputs ($fp, $crypted);
    $Result = fgets ($fp,1024);
    fclose ($fp);
}

Could it be that the above code is not effecient enough or? Can you suggest something more effecient than this!

Thanks
Ncik
 
There are a lot of vaguaries in any kind of internet transaction. I don't see any way to speed up the processing in your script.

I would add a hidden field to the form which the user submits. That hidden field will contain a serial number which is unique to each transaction. Your script will record that serial number when it receives data, and will only put a single serial number's transaction through once.

Also, start output in your script as soon as possible. When the browser detects the new HTML stream, it should blank the screen.



Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Could be an idea! i was thinking of disabling the buttons!

But why is it that i don;t receive anything! i mean the blue progressbar at bottom starts moving but nothing happens!

Do you think its from the gateway's side!? not to blame anyone mind you but just to get the record straight!

Thanks
nick
 
ok! so if i set the timeout to more than 30sec could do the trick or?

If not, how can i detect that there wasn;t an error from on the way out or on the way in!

This is because i have to know if the transacation has been submitted to the bank or not! we are having loads of double or even triple payments for the same transaction! this is surely not due to the code..i'm more than sure that the code is sending the transaction only once!


Thanks
Nick
 
Your problem may very likely be that your users get impatient in the first 10 seconds and hit the back button and resubmit. I don't think increasing the timeout will necessarily solve the problem.

As to how to detect errors, that will depend on your clearinghouse and their software.



Want the best answers? Ask the best questions!

TANSTAAFL!!
 
hmmm! do you suggest something more suitable in this case!

Sorry for my asking but i really have to get this going!

Tahnks once again
Nick
 
I'm suprised that a bank does not supply you with the protocol details to talk to this service i.e. about serial numners, repudiration etc.
 
A lot will also depend on the clearinghouse itself. There are a number of second and third party houses out there and you could very likely be passing your data to their server and in turn they're passing it through another server who in turn finally passes it on the the originating bank. Like a chain, the process will only be as fast as the slowest link. And as ingresman suggests, the clearinghouse usually supplies the methods and protocol for the connection. I think I'd be a little leary of one that doesn't.

There's always a better way. The fun is trying to find it!
 
thanks tviman! I like to try to fnd out myself...but the problem is that i'm playing with people's money! even tough i like the idea i would even play around! so thats why i asked!

The problem is the third party people with whom we are connecting! but i have to do something!

Nick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top