CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2003
    Location
    Korea
    Posts
    60

    Session TPC/IP connection

    Hi everybody,

    I am making a web-based MSN messenger. Here is the program architecture
    (Web Client) <====> (Web Server) <====> (MSN Servers)

    Web Client: I use AJAX to communicate Web Server
    Web Server: Windows 2K, apache server, PHP.
    Web Server connects to MSN Server(s) through TCP/IP sockets


    I have faced one problem for a week. Currently, I could not find out the solution. To LogIn to MSN Server:

    1. Web Client requests login.php page from Web Server
    2. Web Server connects to MSN Server, and Web Server has to keep connection alive with MSN Server until Web Client logs out.
    3. If LogIn is successful, Web Server returns a message to notify that It is successful. Whenever the execution of login.php finishes, the connection with MSN Server is closed immediately by Web Server. I want to keeps that connection alive.

    In Login.php, I create new class, this class establishes conection with MSN Server. And this class is saved in $_SESSION array. This class will be used in subsequent page requests, and connection will be available for subsequent page requests. But In fact, the connection is closed immediately whenever Login.php is returned to client. The class is not used in subsequent pages also. So can you help me to explain me that the problem is, and how to solve it.

    Thank you very much.
    Quang

  2. #2
    Join Date
    May 2002
    Posts
    10,943

    Re: Session TPC/IP connection

    I never knew that MSN servers would interface with anything else but their own software. How have you gotten the information to connect to their servers? Are you sure that it is not their servers that are terminating the connection?
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  3. #3
    Join Date
    Aug 2005
    Location
    southampton, UK
    Posts
    1,320

    Re: Session TPC/IP connection

    I can't see how you ca do this with php. It doesn't have threads i the script cannot accept values from user whilst running - only at the start. So this means every message it gets and sends would required a seperate logon.

    The only thing i could think of is to have a framed site, so that there is an invisible frame somewhere on the page, which points to the location of your msn php script.

    this script would log on, have some of continuos loop checking for changes in a database (new messages going out) and add messages comming in to the database.

    It would then be upto Ajax in another frame to send to and receive the info from the database.

    btw there are quite a few php msn scripts out there on google

    p.s. it may be possible to connect to msn using pure javascript - ask on the ajaz forum
    Last edited by dave2k; April 5th, 2006 at 09:59 AM.
    With sufficient thrust, pigs fly just fine. However, this is not
    necessarily a good idea. It is hard to be sure where they are going to
    land, and it could be dangerous sitting under them as they fly
    overhead. -- RFC 1925

  4. #4
    Join Date
    Jul 2003
    Location
    Korea
    Posts
    60

    Re: Session TPC/IP connection

    I never knew that MSN servers would interface with anything else but their own software. How have you gotten the information to connect to their servers? Are you sure that it is not their servers that are terminating the connection?
    Thank you, guys, for your quick replies.

    MSN Team has not not released any documents about how to connect MSN Servers. But this website http://www.hypothetic.org/docs/msn/index.php provides quite enough information for you to implement an MSN Messenger-like application. You can connect to MSN Server(s) through TCP/IP or through HTTP.

    I'm sure that the problem is caused by Web Server. I wrote my own server to test the problem. The connection is lost when the Web Server returns a page to client.
    Last edited by quangnt; April 5th, 2006 at 11:20 AM.
    Quang

  5. #5
    Join Date
    Jul 2003
    Location
    Korea
    Posts
    60

    Angry Re: Session TPC/IP connection

    To be simple, please do not consider the MSN Server, we just consider the TCP/IP connection
    (Web Server(Apache, PHP)) <==TCP/IP==> (another Server)

    If client requests a page:
    1. Web Server creates connection with "another Server"
    2. Get information from "another server"
    3. Return the page to the client

    At after step 3, the web server closes connection automatically. I want to keep the connection. This is my problem. Do you know the reasons? Thank you very much.

    I think it is a good and useful discussion, maybe PHP can keep atomic data in $_SESSION array, but PHP can not keep complex objects in $_SESSION array. It is why when, after the step 3, the server destroy complex objects, and the connection is destroyed too.
    Quang

  6. #6
    Join Date
    Aug 2005
    Location
    southampton, UK
    Posts
    1,320

    Re: Session TPC/IP connection

    i already told you what happens - before posting take time to read posts others have made before winding people up

    for an msn app you need to find a way to be constantly connected to the msn servers

    if you return a page back to the user, this means your script has stopped executing

    i.e. you have been disconected
    With sufficient thrust, pigs fly just fine. However, this is not
    necessarily a good idea. It is hard to be sure where they are going to
    land, and it could be dangerous sitting under them as they fly
    overhead. -- RFC 1925

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured