简体   繁体   中英

How do i create several persistent socket connection TCP/IP to the same host using PHP

Currently my situation is i have a window server hosting web and will communicate to unix host server(database) to retrieve data whenever user request. I'm using apache and PHP for my window server.

Can i actually create a new persistent socket connection to host whenever a new user log in and the socket will tie to the specific user?

the socket should only tie with one user.

The reason to use persistent socket is because allow user to continue the connection with other pages after the user log in for security purpose. However using persistent socket will only have on connection, if second user come in the user will continue use the existing connection. Second user shouldn't share the same with the 1st user.

i have tried use fsockopen() but whenever go the other page it will start up a new connection and need to re-enter user and password at unix host side.

Is there any way i can keep my server to unix connection stay connected for the same user? if the other user come in will require to login and tie the connection after successful login.

finally able to connect to the same host with multiple persistent socket by contain a "/" followed by a unique identifier

<?php
$identifier = "id1"; //unique identifier for every new persistent socket create
$host = "tcp://mysql.example.com:33/" . $identifier;
$socket = stream_socket_client($host, $errorno, $errorstr, $timeout, STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT);
?>

You need an assisting TCP service on your windows webserver machine, to maintain the connections to your mainframe.

something like: http://www.dart.com/telnet-activex-tool-control.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM