none
.NET 4.0 tcplistener not working in windows 8 RRS feed

  • Question

  • I have an existing WPF application developed in .NET 4.0 that is using windows sockets and a tcplistener to allow some remote control features. This has been working great with XP through 7 for some time. I am testing on Windows 8 and find that the listener is not receiving anything that comes in. I see the StreamSocket class for 4.5, but it says this will not be compatible with Windows 7. Do I have to maintain two versions here or is there any way I can have a version that will run on both win 7 and 8?
    Wednesday, March 13, 2013 5:43 PM

Answers

  • I found the issue here. It looks like the default ReceiveBufferSize on a tcpclient is 8192 bytes when running on windows <=7. When you run the same code on windows 8, the default ReceiveBufferSize is 65536. I was not setting the buffer size and was manually setting the length of my byte array to receive the stream to more than the win7 default but less than the win8 default. I also had the listener loop set to catch this and just start a new listener/thread so it seemed as if it was not receiving the stream. 

    Maybe this will help someone else. I am using my socket app to pass urls, so I will limit my buffer size to the current ie limit of 2083 (some browsers allow longer, but i think this is reasonable). 

    Thursday, March 14, 2013 3:02 AM

All replies

  • I found the issue here. It looks like the default ReceiveBufferSize on a tcpclient is 8192 bytes when running on windows <=7. When you run the same code on windows 8, the default ReceiveBufferSize is 65536. I was not setting the buffer size and was manually setting the length of my byte array to receive the stream to more than the win7 default but less than the win8 default. I also had the listener loop set to catch this and just start a new listener/thread so it seemed as if it was not receiving the stream. 

    Maybe this will help someone else. I am using my socket app to pass urls, so I will limit my buffer size to the current ie limit of 2083 (some browsers allow longer, but i think this is reasonable). 

    Thursday, March 14, 2013 3:02 AM
  • Hi,

    I'm glad to hear that you resolve this issue. Thanks for the useful feedback.

    Best Regards.


    Haixia
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, March 15, 2013 5:37 AM
    Moderator