Hi all,
I have this situation now that requires socket programming. But I am not
sure how to realise the requirements in programming whether as a client or
server
The requirement is like this.
I have to connect to an external server constantly to listen for incoming
data. How can I make sure that the connection is there all the time? Upon
receiving the message, I will have to response back an acknowledgement that
the message is received. I can also send data to the server. From my
requirements, I understand that there will only be one connection. Therefore
the data exchange need not be in sequence.
Currently, what I have is a server programmed using the socket library.
Server logic :
socket_create
socket_bind
socket_listen
while(true)
{
socket_select
if(new connection)
{
add to connections array
}
else
{
if(can read)
{
read incoming
response back
}
else
{
//error or connection close
if(error)
{
print error
}
else
{
print connection close
remove from connections array
}
}
}
}
I am planning to include a check somewhere in the codes for maintaining the
connection between my server and the other server. Where should I place it?
Also, I need to initiate a connection to the external server and then
listen. Where should this piece of code be insert at? Is this the right
approach? Or I am over killing by writing a server if this can be handle in
easier manner.
Hope that I have been clear in the above.
Thanks for helping
Ai Leen
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php