how to make a socket raise events???
how to make a socket raise events???
how to make a socket raise events???
how to make a socket raise events???
how to make a socket raise events???
how to make a socket raise events??? how to make a socket raise events??? how to make a socket raise events??? how to make a socket raise events??? how to make a socket raise events??? how to make a socket raise events??? how to make a socket raise events??? how to make a socket raise events???
how to make a socket raise events??? how to make a socket raise events???
how to make a socket raise events???
Go Back  Xtreme Visual Basic Talk > > > how to make a socket raise events???


Reply
 
Thread Tools Display Modes
  #1  
Old 12-06-2004, 01:43 PM
peanutman's Avatar
peanutman peanutman is offline
Junior Contributor
 
Join Date: Sep 2003
Location: Belgium
Posts: 316
Default how to make a socket raise events???


i'm pretty new to VB.NET , and have a question i haven't found an answer for yet.

In VB6 if you added a Winsock control, it would have this event that is raised every time data arives at the sock.

i am now using sockets in VB.NET. i found out how to retrieve data at any time. but this is anoying since i can't predict when data is going to come.
isn't there a way that could make a socket raise an event or something every time data arives... it would make my life easier..

Reinout,
__________________
http://free-b.org
Reply With Quote
  #2  
Old 12-06-2004, 02:03 PM
excaliber's Avatar
excaliberhow to make a socket raise events??? excaliber is offline
Senior Contributor

* Expert *
 
Join Date: Nov 2002
Location: Ohio, USA
Posts: 1,828
Default

Short answer: Not really

Long answer: Well, yes, but it works on a different theory. There are two ways you could go about it, but both take you out of "synchronous" socket programming. You could spawn a new thread that calls .Recieve (since it blocks, you dont want it on the main thread), and when it gets data it raises an event via a delegate or WithEvents/event (essentially the same thing, delegates just give you more control).

But, if you go that route, the sockets already have something like that built in. It is called asynchronous sockets. Unfortunately, this makes programming sockets far more difficult (though not impossible, and you get many many benefits) as the sockets work independantly of the main thread execution and is all done through Callback delegates (in a thread pool). Synchronizing data becomes a hassle because of the threading, you need to keep states of each socket as the same thread is not guaranteed to work on the same socket each time (due to thread pool), the callback delegates often times end up calling other callback delegates to get/send more information, and sharing data is extremely daunting.

That said, it provides extremely scalable interface, high performance, etc etc. Just more to think about.
__________________
RandomIRC - Your neighborhood's friendly IRC channel (irc.randomirc.com - #code)

"Perl - The only language that looks the same before and after RSA encryption."
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
how to make a socket raise events???
how to make a socket raise events???
how to make a socket raise events??? how to make a socket raise events???
how to make a socket raise events???
how to make a socket raise events???
how to make a socket raise events??? how to make a socket raise events??? how to make a socket raise events??? how to make a socket raise events??? how to make a socket raise events??? how to make a socket raise events??? how to make a socket raise events???
how to make a socket raise events???
how to make a socket raise events???
 
how to make a socket raise events???
how to make a socket raise events???
 
-->