Groups | Blog | Home
all groups > dotnet sdk > may 2004 >

dotnet sdk : Socket Help (Client/Server App)


Ghazanfer
5/17/2004 10:56:02 PM
I have made a client server app in VB.Net. I used Tcpistener in server app and TcpClient in client app. My server supports multiple clients. There is a separate thread for each client that connets to the server so they can exchange msgs. The problem i m facing is that when i close the Client app the client socket on the server side dose not close. I ckeched it by retreiving the protected property of TcpClient 'Client' to check whether the scoket is connected or not. Its 'Connected' property returns true that means the client socket is alive. Due to this problem i can not close/exit the respective client thread

Yuancai (Charlie) Ye
5/18/2004 11:43:57 AM
Hi,
At this time, dotNet mainly supports blocking socket. dotNet has very
little support to non-blocking socket and forgets all of socket
communication events such as OnClose, OnAccept, OnDataArrive, OnWrite,
OnConnect etc. You must fight your problems by sending data periodically for
detecting network connection. It is truly ugly, but you have no other
choice. Our SocketPro implements these events. For details, see the VB
samples inside the package SocketPro at www.udaparts.com

--
Yuancai (Charlie) Ye

Fast and securely accessing all of remote data sources anywhere with
SocketPro using batch/queue, asynchrony and parallel computation

See 30 well-tested and real OLEDB examples

RDB, a tool for fast and securely accessing remote databases with dial-up,
cable, DSL and wireless modems anywhere
www.udaparts.com


[quoted text, click to view]
and TcpClient in client app. My server supports multiple clients. There is a
separate thread for each client that connets to the server so they can
exchange msgs. The problem i m facing is that when i close the Client app
the client socket on the server side dose not close. I ckeched it by
retreiving the protected property of TcpClient 'Client' to check whether the
scoket is connected or not. Its 'Connected' property returns true that
means the client socket is alive. Due to this problem i can not close/exit
the respective client thread.
[quoted text, click to view]

Chad Z. Hower aka Kudzu
5/18/2004 5:11:25 PM
=?Utf-8?B?R2hhemFuZmVy?= <anonymous@discussions.microsoft.com> wrote in
news:86324324-0E58-4529-9B85-158BEA77BC35@microsoft.com:
[quoted text, click to view]

You misunderstand how sockets work. The Connect property can only "update"
itself during reads and writes. So if you disconnect but then dont read or
write, it cannot know this. This is why most protocols when they disconnect
agree to disconnect first.



--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Make your ASP.NET applications run faster
Feroze [MSFT]
5/24/2004 3:55:50 PM
Can you give more information on why you think "dotnet has very little
support on non-blockiing socket" ?

System.Net.Sockets.Socket class supports asynchronous usage. If there are
particular issues that you found, I would be happy to hear about them.

As regards events: yes, Sockets doesnt support events, although we are
working to rectify this in a future version.

THanks.
--
feroze
http://weblogs.asp.net/feroze_daud
============

Remove "user" from the email address to reply to the author.

This posting is provided "AS IS" with no warranties, and confers no rights

Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm




[quoted text, click to view]

Yuancai (Charlie) Ye
5/26/2004 12:29:59 PM
Hi,
These events are extremely important for developing a full non-blocking
socket application. Dotnet socket implementation is poor in comparison to
native window system socket 2 APIs. System.Net.Sockets.Socket class supports
asynchronous usage through dotnet interface IAsyncResult with creating extra
threads. Native window system socket 2 APIs do not require extra threads at
all, which avoids all of thread side effects such as dead lock and data
synchronization etc.

--
Yuancai (Charlie) Ye

Fast and securely accessing all of remote data sources anywhere with
SocketPro using batch/queue, asynchrony and parallel computation with online
compressing

See 30 well-tested and real OLEDB examples

www.udaparts.com


[quoted text, click to view]

feroze [msft]
6/30/2004 11:42:21 PM
I dont disagree with you that Eventing model is important for a good
developer experience, esp for the begining developer. However, eventing is
not the be-all and end-all of writing a non-blocking application.

I disagree with your assertion that System.Net.Sockets implementation is
poor in comparison to native winsock2 apis. The Sockets classes are based on
tthe winsock2 apis. On WindowsNT platforms, we use I/O completionports to
give you the best performance. On Win9x platforms, Overlapped I/O is used.
In this case you might see an extra thread.

On NT, there is no extra thread created when you use async i/o.

feroze
=====================================

[quoted text, click to view]

AddThis Social Bookmark Button