Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / .NET SDK / July 2004

Tip: Looking for answers? Try searching our database.

Socket Help (Client/Server App)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ghazanfer - 18 May 2004 06:56 GMT
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

please help.
Chad Z. Hower aka Kudzu - 18 May 2004 15:11 GMT
=?Utf-8?B?R2hhemFuZmVy?= <anonymous@discussions.microsoft.com> wrote in
news:86324324-0E58-4529-9B85-158BEA77BC35@microsoft.com:
> 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.

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
 http://www.atozed.com/IntraWeb/
Yuancai \(Charlie\) Ye - 18 May 2004 16:43 GMT
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

Signature

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

> 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.

> please help.
Feroze [MSFT] - 24 May 2004 23:55 GMT
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.
Signature

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

> Hi,
>     At this time, dotNet mainly supports blocking socket. dotNet has very
[quoted text clipped - 16 lines]
> >
> > please help.
Yuancai \(Charlie\) Ye - 26 May 2004 17:29 GMT
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.

Signature

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

> Can you give more information on why you think "dotnet has very little
> support on non-blockiing socket" ?
[quoted text clipped - 30 lines]
> > >
> > > please help.
feroze [msft] - 01 Jul 2004 07:42 GMT
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
=====================================

> Hi,
>     These events are extremely important for developing a full non-blocking
[quoted text clipped - 47 lines]
> > > >
> > > > please help.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.