INTERACT FORUM

Windows => Plug-in Development => Topic started by: zigguratt on July 05, 2002, 07:01:33 am

Title: Multiple socket question
Post by: zigguratt on July 05, 2002, 07:01:33 am
I'm trying to modify Web Remote so it can service more than one client simultaneously. With web pages this isn't normally a problem as the connection is momentary. But with XML socket connections the socket is held open indefinitely.

It seems that if there's an XML socket open and a second client requests a web page (opening and closing another socket), the XML socket is closed as well - or at least mutilated somehow - cutting off the XML client.

Is this normal behaviour? I would think that one socket's closing shouldn't affect others.
Title: RE:Multiple socket question
Post by: Nikolay on July 08, 2002, 11:18:44 am
I bet our HTML server code is not working correctly.
Send us the source code and we will take a look.

Nikolay
Title: RE:Multiple socket question
Post by: zigguratt on July 08, 2002, 12:17:21 pm
Thanks, Nikolay. I've sent the source to Matt, as I don't know your email address.
Title: RE:Multiple socket question
Post by: zigguratt on July 15, 2002, 05:14:41 am
Any ideas as to what the problem might be, Nikolay?
Title: RE:Multiple socket question
Post by: Nikolay on July 16, 2002, 06:36:13 am
zigguratt,

I got the source, but we are very busy with MJ 8.0 fixes. I think I'll get to it today or tomorrow.

Nikolay
Title: RE:Multiple socket question
Post by: Nikolay on July 16, 2002, 09:37:43 am
Here is the fix:

replace this code in HTTPMJServer.cpp

 ACCEPT_STRUCT accept_Info;
 accept_Info.pParent = pParentClass;
 accept_Info.iAcceptSocket = isocket;

 HANDLE hAccept = (HANDLE)_beginthread(AcceptThread, 0, &accept_Info);

with following:
 ACCEPT_STRUCT * pAccept_Info = new ACCEPT_STRUCT;
 pAccept_Info->pParent = pParentClass;
 pAccept_Info->iAcceptSocket = isocket;

 beginthread(AcceptThread, 0, pAccept_Info);

add
delete accept_Info;

after this code:

Close:
closesocket(accept_Info->iAcceptSocket);
g_ServerInfo.iNumConnected--;



Nikolay
Title: RE:Multiple socket question
Post by: zigguratt on July 16, 2002, 09:43:14 am
Excellent, Nikolay.  Now you've done it.  I'll have to make another release with CD cover art support.

;)
Title: RE:Multiple socket question
Post by: zigguratt on July 16, 2002, 09:55:59 am
Yep, that fix worked.  Now any number of clients can connect at the same time.  This will make retrieval of cover art possible now.

Woohoo!  Thanks, Nikolay.