Page 1 of 1

Socket Server act as Requester and Listener at the same time

Posted: Wed Apr 11, 2007 7:36 am
by Suhendri
Is it possible to create socket server with PHP to handle request from client and forward the request to service provider server, wait the respon for service provider server and forward the respon to the client. And at the same time the service provider server may send request to socket server and wait respon from socket server.

Figure:

Code: Select all

Client -----1----> Socket Server -----2----> Service Provider Server
Client <----4----- Socket Server <----3----- Service Provider Server
                   Socket Server <----3a---- Service Provider Server
                   Socket Server -----3b---> Service Provider Server
Currently i have 2 socket server, first handling request from client and forward to Service Provider Server (1, 2, 3, 4)
and the second handle request from service provider server (3a and 3b).

The service provider allowed only one connection session from socket server to the service provider. With that policy, what i have with 2 socket service do not meet their criterion..

If i combined 2 socket server to 1 socket server, i have problem to handle the request from client and request from service provider. The problem are how to handle the respon and request from service provider.

I accepted the request from client using socket_select and socket_read, after that i reroute the request to service provider server using socket_write and wait respon from server using socket_read. If the respon arrived, i forward it to the client using socket_write.

With that flow of process, i don't know how to receive and respon the request from service provider server.

Desperately needed help for my problem above..

Thanks in advance...

ps. Sorry for my Terrible English

Posted: Thu Apr 12, 2007 8:31 pm
by Suhendri
Lets make it simple..

The server defined to act like a router. Forwarding packet from A to B.

Is it hard to create socket server like that ? :roll: