开发者

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 g开发者_运维问答et 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!


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜