• Home
  • About
  • BestBloggingIdeas
  • DotNetLearningSource
  • FORUM
  • Joblinks
  • Latest News
  • Policy
  • POSTS
  • SimplySqlServer.Com && SimplyAspDotNet.Com
  • Sitemap

Join Ours Forum

Asp.Net,C#,Ajax,Sql server,silverlight,Javascript codes exambles articles,Programming exambles

RSS Feed
  • Bounty Huge Roll [Amazon Frustration-Free Packaging]
  • XML Introduction to XML VHS Video Training, 1 hr., 32 minutes.
  • The Basic Overview of Windows Mobile Development Asp.Net C#
  • Overview of Sql server extended properties Asp.Net C#
  • How to Use Sql Server Extended properties using visual studio Asp.Net C#
  • Adobe Dreamweaver Templates Accelerate Web Development
  • Top Tips for Web Design Projects
  • How to Achieve a Good Web Design Structure
  • To Use Or Not To Use Website Templates
  • Five Tips to a Successful Website
  • Top 10 Articles,


    Silverlight Datagrid Select Update Delete Insert Asp.Net C#

    Differences Similarities Benefits Between Typed Datasets and Untyped Datasets asp.net c#

    Linq to Sql Introduction Entities Ado.Net C# SqlClasses Attributes Linq Mapping

    Linq Programming/How Linq Works?/Linq Implementation In Asp.Net C# Ado.Net

    Performing Developing Using Investigating Asp.Net 2.0 Ajax Application Development Asp.Net C#

    Hosting/Install Wcf Services in a Windows Service Asp.Net C#

    Connecting Silverlight to Wcf Asp.Net C#

    Silverlight Data Grid Data Binding WCF Asp.Net C#

    Invoking/Accessing/Calling WCF Service Without Adding/Creating Proxy/Reference Asp.Net C#

    Performing Doing Creating Insert Update Delete sql data Using Linq Database Asp.Net C#

    How to Create Socket Programming in ASP.NET

    Posted by on November 19, 2009 Leave a comment (30) Go to comments

    The classes in the System.Net.Sockets namespace provide sockets support in .NET.

    The System.Net.Sockets contains the following Properties,

    AddressFamily
     Gets the address family of the socket. The value is from the Socket.
    AddressFamily enumeration.
     
    Available
     Returns the amount of available data to read.
     
    Blocking
     Gets or sets the value that indicates whether the socket is in blocking mode.
     
    Connected
     Returns the value that informs whether the socket is still connected
    with the remote host.
     
    LocalEndPoint
     Gets the local endpoint.
     
    ProtocolType
     Get the protocol type of the socket.
     
    RemoteEndPoint
     Gets the remote endpoint of a socket.
     
    SocketType
     Gets the type of the socket.
     
    SupportsIPv4
     Returns a Boolean value indicating whether IPv4 is available on the current host.
     This property is supported in only version 1.1 of the Framework.
     
    SupportsIPv6
     Returns a Boolean value indicating whether IPv6 is supported and available
     on the current host. This property is supported in only version 1.1 of the Framework.

    The System.Net.Sockets Contains the following methods,

    Accept
     Creates a new socket to handle the incoming connection request.
     
    Bind
     Associates a socket with the local endpoint for listening for incoming connections.
     
    Close
     Forces the socket to close itself.
     
    Connect
     Establishes a connection with the remote host.
     
    GetSocketOption
     Returns the value of a SocketOption.
     
    IOControl
     Sets low-level operating modes for the socket. This method provides low-level access to the underlying socket instance of the Socket class.
     
    Listen
     Places the socket in listening mode. This method is exclusively used to server applications.
     
    Receive
     Receives data from a connected socket.
     
    Poll
     Determines the status of the socket.
     
    Select
     Checks the status of one or more sockets.
     
    Send
     Sends data to the connected socket.
     
    SetSocketOption
     Sets a SocketOption.
     
    Shutdown
     Disables send and receive functions on a socket.

     
    See the below examble,
       Simply the Server is responding to client using Socket
    Programming.

     

    using System;
    using System.Net.Sockets; //Namespace Supports Socket Programming
    using System.Net;
    using System.Text;
    public class SocketServer
    {
       public static void Main(string [] args)
       {
          // Establish the local endpoint for the socket
          IPHostEntry ipHost = Dns.Resolve(“localhost”);
          IPAddress ipAddr = ipHost.AddressList[0];
          IPEndPoint ipEndPoint = new IPEndPoint(ipAddr, 11000);
          // Create a TCP/IP socket
          Socket sListener = new Socket(AddressFamily.InterNetwork,
                                        SocketType.Stream, ProtocolType.Tcp);
          // Bind the socket to the local endpoint and
          // listen to the incoming sockets
          try
          {
             sListener.Bind(ipEndPoint);
             sListener.Listen(10);
             // Start listening for connections
             while (true)
             {
                Console.WriteLine(“Waiting for a connection on port {0}”,ipEndPoint);
                // Program is suspended while waiting for an incoming connection
                Socket handler = sListener.Accept();
                string data = null;
                // We got the client attempting to connect
                while(true)
                {
                   byte[] bytes = new byte[1024];
                   int bytesRec = handler.Receive(bytes);
                   data += Encoding.ASCII.GetString(bytes,0,bytesRec);
                   if (data.IndexOf(“<TheEnd>”) > -1)
                   {
                      break;
                   }
                }
                // Show the data on the console
                Console.WriteLine(“Text Received: {0}”,data);
                string theReply = “Thank you for those ” + data.Length.ToString()
                                + ” characters…”;
                byte[] msg = Encoding.ASCII.GetBytes(theReply);
                handler.Send(msg);
                handler.Shutdown(SocketShutdown.Both);
                handler.Close();
             }
          }
          catch(Exception e)
          {
             Console.WriteLine(e.ToString());
          }
       } // End of Main
    }

    Now,i hope you got atleast a basic idea of socket Programming,

    Happy Coding

    ASP.NET
    ← JSON-Introduction
    Sending Mail to SMTP Server using Asp.Net →

    Learn Easily Using Video Tutorials


    How to choose the right Java IDE – explained Eclipse NetBeans BlueJ

    Developing/Creating/Performing/Configuring Java Applications Using Eclipse IDE

    Step By Step Guide for Download/Install Configure Eclipse IDE for Java

    Editing data with the GridView control Asp.Net C#

    Registering/Configuring Web Controls globally in web.config file asp.net c#

    Registering/Configuring Web Controls globally in web.config file asp.net c#

    Best way to prepare asp.net Interview - Success Stories

    Download Important Questions and PPT's:

    Sql Server Important Questions Online free download

    Dotnet Important Questions Online free download

    Exploring Linq to Sql Process Flow

    Learn how to perform silverlight programming

    Learn OOPs concepts in better and well manner

    Learn Ajax in better and well manner

    Leave a comment

    30 Comments.

    1. Amsterdam Escort April 29, 2010 at 10:01 pm

      I enjoyed viewing your blog and I will be back to check it more in the future so please keep up your good quality work. I love the colors that you chose, you are quite talented!

    2. Natalia Romero May 1, 2010 at 12:42 pm

      Awesome work! Very inspiring!

    3. Hsiu Kukielka May 4, 2010 at 11:14 pm

      Great blog , i will bookmark it right now !

    4. BMW May 20, 2010 at 10:33 am

      Nice post…Thank you for sharing some good things.

    5. uspto patent June 2, 2010 at 6:26 pm

      This is my first time i visit here. I found so many interesting stuff in your blog especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the enjoyment here! keep up the good work.

    6. uspto patent June 3, 2010 at 3:13 am

      Well, I have been reading your blog posts daily and the reason I come on your blog frequently is its compelling content… Regards…

    7. uspto patent June 3, 2010 at 11:02 am

      Guys, Great article and very very interesting blog. That’s one thing I’m really looking forward. Looking forward to reading more from you next week.

    8. Gucci Handbags June 17, 2010 at 10:51 pm

      I feel you are too good to write Genius!Thanks for posting, maybe we can see more on this.

    9. jasa web design June 21, 2010 at 8:02 pm

      This is my first time i visit here. I found so many interesting stuff in your blog especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the enjoyment here! keep up the good work.

    10. Renetta Folliard June 23, 2010 at 3:55 pm

      Fantastic website. Keep undertaking.

    11. hannah montana fashion July 10, 2010 at 2:24 am

      Hi there! We are seeking for incoming writers, may you be attracted? This situation isn’t going to make you wealthy nonetheless there is an interesting pay and if you absolutely take pleasure in freelance writing then that gig is for you.

    12. My Wordpress Journey July 11, 2010 at 11:24 am

      This is the type of information that should be shared around the web. Shame on the search engines for not positioning this post higher!

    13. hannah montana fashion July 11, 2010 at 5:06 pm

      Your web blog is recording glitches on my Windows internet browser.

    14. Kredyty July 19, 2010 at 8:33 am

      I’ve been visiting your blog for a while now and I always find a gem in your new posts. Thanks for sharing.

    15. Carlos Boozer Chicago Bulls July 26, 2010 at 5:39 am

      Thank you for the sensible critique. Me & my neighbour were preparing to do some research about that. We got a good book on that matter from our local library and most books where not as influensive as your information.

    16. tahitian noni July 28, 2010 at 4:05 pm

      You certainly deserve a round of applause for your post and more specifically, your blog in general. Very high quality material

    17. Pilipinas Win na Win July 28, 2010 at 5:28 pm

      How are you ? ! Do you maintain some variety of gift box where I might transmit donation in PayPal?

    18. James(Author) July 28, 2010 at 6:31 pm

      Hello sir,thanks for yours support, please use the donate button in header,it helps me to grow further.Thanks

    19. scuba diving July 30, 2010 at 3:37 pm

      I just sent this post to a bunch of my friends as I agree with most of what you’re saying here and the way you’ve presented it is awesome.

    20. karty kredytowe August 5, 2010 at 9:16 am

      I just book marked your blog on Digg and StumbleUpon.I enjoy reading your commentaries.

    21. Kenton Butt August 6, 2010 at 3:53 am

      I truly liked this post, this one is going right into my stumble upon account :)

    22. Adalberto Lauwers August 7, 2010 at 2:29 am

      I enjoy the way you catch the substance of the idea, truly great writting layout, I enojoyed it!

    23. Jhonny Peralta Stats August 11, 2010 at 10:52 am

      I’ve really enjoyed reading your articles. You obviously know what you are talking about! Your site is so easy to navigate too, I’ve bookmarked it in my favourites. . . . .

    24. Jhonny Peralta Stats August 12, 2010 at 3:59 am

      It’s good to see this information in your post, i was looking the same but there was not any proper resource, thanx now i have the link which i was looking for my research. . . . . .

    25. Doradztwo finansowe August 13, 2010 at 7:21 am

      Very good post. Hope to see more excellent posts in the future.

    26. Trevor Crookshanks August 14, 2010 at 6:23 am

      I really love your post. If it’s not too much trouble, can you perhaps show how to write works such as this. Trevor Crookshanks

    27. sok noni August 25, 2010 at 5:04 am

      I just sent this post to a bunch of my friends as I agree with most of what you’re saying here and the way you’ve presented it is awesome.

    28. How to Start Online Business October 11, 2010 at 5:54 am

      Great news mann !

    29. thank you cards December 23, 2010 at 8:30 am

      Im confident you do not know me so that well I do not know you. nonetheless I really like with regards to all you possess presented from the article higher than. whenever I really could uncover places to obtain inspiration to jot down that good. I am a critic in my america, but rarely I find penning this healthy. frankly I’m jealous as in you. by the way May I have your email address can I confer with? I would like to speak using your firm. say thanks a ton

    Leave a Reply Cancel reply

    Your email address will not be published. Required fields are marked *

    *

    *


    You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

    Trackbacks and Pingbacks:

    • Socket : 80208 - Pingback on 2010/01/29/ 15:57

    Enter your email address:

    Delivered by FeedBurner

    • Recent Posts

      • Bounty Huge Roll [Amazon Frustration-Free Packaging]
      • XML Introduction to XML VHS Video Training, 1 hr., 32 minutes.
      • The Basic Overview of Windows Mobile Development Asp.Net C#
      • Overview of Sql server extended properties Asp.Net C#
      • How to Use Sql Server Extended properties using visual studio Asp.Net C#
    • Search by Tags!

      Application AspNet Basic between Black Bluetooth Build Business Collection Consultants Design Development Downloading effective Excel Experts Generics Implement Installing Interview Logic Management Microsoft Minutes Object Outlook Professional Programmer Programming Project Projects Questions Ready Select Server Services Silverlight Source Strings Studio Through using Visual Website Wordpress
    • Archives

      • August 2011
      • June 2011
      • May 2011
      • April 2011
      • March 2011
      • February 2011
      • December 2010
      • November 2010
      • October 2010
      • September 2010
      • August 2010
      • July 2010
      • June 2010
      • May 2010
      • April 2010
      • March 2010
      • February 2010
      • January 2010
      • December 2009
      • November 2009
      • October 2009
      • September 2009

    Copyright © 2012 NetProgrammingHelp.com

    Δ Top