MWard
MWard

Reputation: 135

Asynch Socket Server and AS3 Flash Application - User Disconnects not handled

I have 2 sets of code for you to look at, both are available at PasteBin here:

First is my c# Socket server: http://pastebin.com/wvT4f19m

Second is my code within my AS3 application: http://pastebin.com/bKvabFSP

In the code, what I am trying to do is a simple Send/Receive to see what happens. If I open my application in 2 instances the c# socket server registers that they exist and all is fine!. If I close one of my instances, the c# server still thinks that the user exists and the socket isn't closed.

My code is based off the example at : http://msdn.microsoft.com/en-us/library/fx6588te.aspx

In the MS example, the following lines are added to the SendCallBack() function:

handler.Shutdown(SocketShutdown.Both);
handler.Close();

These definately close the sockets, something I do not want to happen.

I am new at socket programming and it has taken me a fair amount of time to play with the MS example to get it working roughly how I need it. The only problem is the acknowledgement of user disconnects so that I can remove the user from the Clients list that I have set up in the server. Also, when disconnects are acknowledged, I can inform other clients.

thanks all!

Upvotes: 1

Views: 807

Answers (2)

MWard
MWard

Reputation: 135

Upon each attempt to send data to the user, I do a quick check for a successful transmission/Poll the user and if it fails, the user is removed from my server.

Upvotes: 1

TheCodeKing
TheCodeKing

Reputation: 19220

Closing the socket won't affect your listener, it will only affect the current connection. Why do you say this is not what you want?

It sounds like this is exactly what you want.

Upvotes: 0

Related Questions