const int portNumber = 13;
TcpListener tcpListener = new TcpListener(portNumber);
tcpListener.Start();
Console.WriteLine("Waiting for a connection....");
try{
//Accept the pending client connection and return a TcpClient initialized for communication.
TcpClient tcpClient = tcpListener.AcceptTcpClient();
Console.WriteLine("Connection accepted.");
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;
using System.Threading;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
CheckForIllegalCrossThreadCalls = false;
}
An Asynchronous Socket Server and Client
By Andre Azevedo
An asynchronous socket server and client with encryption and compression.
http://www.codeproject.com/KB/IP/AsyncSocketServerandClien.aspx
A Chat Application Using Asynchronous UDP sockets
By Hitesh Sharma
This article shows how to develop a chat application using UDP sockets.
http://www.codeproject.com/KB/IP/ChatAppAsynchUDPSocks.aspx