.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
Kaviya Balasubramanian
Imran Ghani
Post New Web Links

Looking 4 a simple TCPClient.BeginConnect sample...

Posted By:      Posted Date: December 04, 2010    Points: 0   Category :.NET Framework
 

Networking code, makes my head hurt.

I am trying to create a class that implements a form of connectionless messaging. I have my DoSendMessage method  that is using TCPClient.Connect but the problem is that if the server is not availible the Connect method hangs for about 5 secs while it tries to connect. Meaning my application also hangs. Very bad....

What I am looking for is a COMPLETE and WORKING sample that is simple and uses the asynronous method for connecting using TCPClient.BeginConnect. But I have not been able to track down any easy to fallow sample code.

Does anybody know of any tutorials or links that can help me out. Thanks in advance!

My code is as fallows ...

  Private Sub DoSendMessage(ByVal Server As IPAddress, ByVal Port As Integer, ByVal Message As String, ByVal Raiseevents As Boolean)
        If Server Is Nothing Then Exit Sub
        ' If Server = String.Empty Or Message = String.Empty Then Exit Sub
        ' If Server.Contains(":") Then Server = Server.Substring(0, Server.IndexOf(":"))

        Try
            ' Create a TcpClient.
            ' Note, for this client to work you need to have a TcpServer
            ' connected to the same address as specified by the server, port
            ' combination.
            Dim client As New TcpClient
            client.ExclusiveAddressUse = False
            client.


View Complete Post


More Related Resource Links

Windows UI: Our WinMgr Sample Makes Custom Window Sizing Simple

  

Programmers using Visual Basic have always had an advantage over C++ programmers when it comes to component and window sizing. There are many third-party Visual Basic-based solutions to this age-old problem, but unfortunately, there are few elegant alternatives for the C++ crowd, short of using a full-fledged windowing toolkit. This article explains how to circumvent the tedious task of hardcoded pixel arithmetic. It starts by introducing a window sizing rules system, and then moves on to show how CWinMgr, a data-driven class, can intelligently manage an MFC application's window sizing.

Paul DiLascia

MSDN Magazine July 2001


Looking for a simple Service and Console Client REST sample implementing BASIC authentication

  

Does anyone know of a C# code sample demonstrating WCF REST services and console test client with OperationContracts (GET and POST) implementing mutiple paramaters using BASIC authentication? Also, perhaps, using Fiddler as a test client as well? I have searched high and low for something like this, but have not had any success.


A Simple Sample of a TcpListener and Client

  

Well For the last 2 weeks I been going threw all the samples on google that I can fine. and well they just don't work in a windows form. Ir they just don't work.

 

The Sever

I have one TextBox and 2 buttons (Start and Stop)

 

The Client

I have 2 text box and 3 buttons

Textbox 1 is for messages from server

Textbox 2 is for that user to send message and a button to send

The other 2 buttons are (Connect and DisConnect)

 

Can any one tell me where I can get a Simple TcpListener and and TcpClient for a windows Form that is that simple.

Thanks

Joe

 

 

 


Toppers BBS http://toppersbbs.dtdns.net C# Windows and Console applications. PHP, Mysql. HTML

Sample: Creating Simple Web Part Mashups with InfoPath 2010

  
Explore the code as you learn to create a simple Web Part mashup on SharePoint Server 2010 with InfoPath 2010 and the InfoPath Form Web Part.

Creating a Simple Class in C#

  
The second article in the C# Object-Oriented Programming tutorial describes how classes are created in C# and how behaviour, in the form of publicly visible and private, hidden methods can be added. This demonstrates some of the uses of encapsulation

A Simple and Extensible Radio Button Style GridView

  
The GridView is one of the significant controls in ASP.NET 2.0 and later versions. No doubt it reduces a lot of work time. However, customizing the GridView control is not an easy task. For example, it's hard to add a radio button column to the GridView. This article demonstrates the reason why a radio button column cannot act as normal and how to create a simple and extensible radio button GridView.

Abstract Factory Design Pattern (Sample in C# and VB .NET)

  
An abstract factory provides an interface for creating families of related objects without specifying their concrete classes. Sometimes one wants to construct an instance of one of a suite of classes, deciding between the classes at the time of instantiation. In order to avoid duplicating the decision making everywhere an instance is created, we need a mechanism for creating instances of related classes without necessarily knowing which will be instantiated.

Silverlight Simple Animation

  
Silverlight has several built in techniques for animating controls. Many of these technologies are particularly useful for creating simple animations meant to decorate a web page with eye catching movement that draws the reader's attention. In this post I will skip over these decorative technologies, and instead show how to create a simple animation using a technique similar to those used in many games.

I thought this would be simple... Trying to create a login does an ajax check before submit

  

I have the standard .net login control that is working.  (Still learning .net after 15yrs of classic)

What I want to do is OnButtonClick run a javascript function (to do an ajax call to the db to check if login is valid or not) and if it returns true, then submit the form normally, else don't submit. The piece that I can't figure out, is how to correctly override the default click even to hit my JS routine and then submit the form properly afterwards.

Thanks ahead of time


Looking for ASP.Net JQuery Post Sample

  

Hi, iam looking for a JQuery Post Sample, without reload of the current Page. I want on a webform enter a search text, onclick on the submit button i want get (webservice?) back clean html code that will be shown in a div tag
i found something like

<form id="formsearch" onsubmit="jQuery.ajax({type:'POST',dataType:'html',data:jQuery(this).serialize(),success:
function(data, textStatus){jQuery('#ajaxcontent').html(data);},beforeSend:function(XMLHttpRequest){$('#indicatorSearch').
show();},complete:function(XMLHttpRequest, textStatus){$('#indicatorSearch').hide();},
url:'/Search'}); return false;" action="/Search" method="post">

but how is the source asp.net (or webservice) build up?

can you give me some samples, how i can realize that with asp.net

thanks


Easy Async: Build Concurrent Apps From Simple F# Expressions

  

In this article, the author explores how the F# language helps you create asynchronous function libraries that can be called seamlessly from any other .NET-compliant language.

Chance Coble

MSDN Magazine October 2008


Wicked Code: Silverlight Page Turning Made Simple

  

As we'll show, with just a few lines of JavaScript you can build a general-purpose framework for incorporating page turns into Silverlight 1.0 apps.

Jeff Prosise

MSDN Magazine May 2008


Secure Habits: 8 Simple Rules For Developing More Secure Code

  

Never trust data, model threats against your code, and other good advice from a security expert.

Michael Howard

MSDN Magazine November 2006


Mutant Power: Create A Simple Mutation Testing System With The .NET Framework

  

With mutation testing, the system under test is changed to create a faulty version called a mutant. Here James McCaffrey explains how to do this in .NET.

James McCaffrey

MSDN Magazine April 2006


XML in .NET: .NET Framework XML Classes and C# Offer Simple, Scalable Data Manipulation

  

Microsoft .NET introduces a new suite of XML APIs built on industry standards such as DOM, XPath, XSD, and XSLT. The .NET Framework XML classes also include innovations that offer convenience, better performance, and a more familiar programming model, tightly coupled with the new .NET data access APIs-ADO.NET. XmlWriter, XmlReader, and XmlNavigator classes and classes that derive from them, including XMLTextReader and XMLTextWriter, encapsulate a number of functionalities that previously had to be accomplished manually. A discussion of the XMLDOM-Document is also included.

Aaron Skonnard

MSDN Magazine January 2001


Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend