Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8424793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:06:09+00:00 2026-06-10T04:06:09+00:00

I develop a chat-like application, my server should be written in PHP and client

  • 0

I develop a chat-like application, my server should be written in PHP and client should be a passive one, just listening for data.

Right now i want to start with having two scripts:
send.php
and
server.php

send.php provides REST API to send message to another client via GET interface.

server.php should be a TCP server accepting connections from clients, for the sake of the sending data via sockets and is currently based on http://php.net/manual/en/sockets.examples.php, so right now clients only connect to him and he sends back some test string.

My problem is that i should somehow connect send.php and server.php so that when message was pushed via send.php server.php would actually send it.

How do i do that?

One option i guess is to store pushed messages in a server store and to check for new messages in server.php, but i fear it’s too resource-consuming.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T04:06:11+00:00Added an answer on June 10, 2026 at 4:06 am

    Solution 1.

    I solved my problem in a way i originally suggested, meaning i made server.php active so it checks for new information every second:

    function getNewMessages()
    {
        $arrOfMessages = array();
        $selectQuery = "SELECT * FROM messages WHERE unread=1";
        $result = mysql_query($selectQuery);
        return $arrOfMessages;
    }
    
    if(count($newMessages) > 0)
    { ... } 
    

    Realizing that making SELECT once in a second is not much of a work.

    Solution 2.

    Another approach i guess would look like this:

    • server.php accepts data about client IP and binds it to user session;
    • storing it in database; send.php opens new connection with client and
      sends message to it.

    This way messages would be sent to client immediately after they got ‘sent’ via REST interface by sender client, no checking loops would be running anywhere. You can even make your server.php (title becomes misleading in this solution btw) accept IPs via REST interface, so no additional TCP/UDP connection would be needed.

    Solution 3.

    Many clients (like iOS) this days have push notifications system and if client doesn’t get too many messages per day, the best way to do this is to deliver them is via push notifications. This way you wouldn’t have to have low-level network connections and REST interface would be enough.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm trying to develop a client-server chat application using java servlets and mysql(innoDB engine)
I want to develop a chat application with a server/client model, opening TCP or
I develop a client-server application and I have log in the server, so I
I want to develop a website web chat application like yahoo. Only difference is
I would like to develop a live chat application, to allow Web users to
suppose if i want to develop a windows chat application then a chat server
I have to develop a multiple users chat application (like msn). I don't what
I'm looking to develop a WCF voice chat application. I would like to use
I want to develop a anonymous chat website like http://omgele.com . I know that
I've to develop an android application that allows users to chat I want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.