RcBuilder@walla.com
call centre: 054-5614020

Network Stream Using Socket Async

Posted by: RcBuilder  /   Category: Network / Socket / SOURCE CODE / Stream / TCP / Value Types   /   No Comments
17
Jun
2014

Network Stream Using Socket Async SERVER  public class Server { private Socket listener = null; private const int PORT = 6655; private bool isListening = false; private Encoding encoder = Encoding.UTF8; public void Start() { if (isListening) return; isListening = true; listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); listener.Bind(new IPEndPoint(IPAddress.Any, PORT)); listener.Listen(0); listener.BeginAccept(onSocketAccepted, null); } private void onSocketAccepted(IAsyncResult ar) // LOOP { using (var client = listener.EndAccept(ar)) HandleClient(client); listener.BeginAccept(onSocketAccepted, null); } private void HandleClient(Socket client) { var buffer_read = new byte; int.

Read more

Network Stream Using Socket

Posted by: RcBuilder  /   Category: Network / Socket / SOURCE CODE / Stream / TCP / Value Types   /   No Comments
17
Jun
2014

Network Stream Using Socket SERVER public class Server { private Socket listener = null; private const int PORT = 6655; private Encoding encoder = Encoding.UTF8; public void Start() { using (listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)) { listener.Bind(new IPEndPoint(IPAddress.Any, PORT)); listener.Listen(100); // connection pool while (true) { using (var client = listener.Accept()) { var buffer_read = new byte; int bytes_read = client.Receive(buffer_read); string request = string.Empty; if (bytes_read > 0) { using (var ms = new MemoryStream()) { ms.Write(buffer_read,.

Read more

Network Stream Using TCP

Posted by: RcBuilder  /   Category: Network / Socket / SOURCE CODE / Stream / TCP / Value Types   /   No Comments
17
Jun
2014

Network Stream Using TCP SERVER public class Server { private TcpListener listener = null; private const int PORT = 6655; private Encoding encoder = Encoding.UTF8; public void Start() { listener = new TcpListener(IPAddress.Any, PORT); listener.Start(); while(true){ using (var client = listener.AcceptTcpClient()) { string request = string.Empty; using (var stream = client.GetStream()) { // read request from client using (var ms = new MemoryStream()) { byte; int bytes_read = 0; bytes_read = stream.Read(buffer_read, 0, buffer_read.Length); if (bytes_read.

Read more
  • פיתוח מערכות
  • פתרונות טכנולוגים
  • קידום אתרים
  • בניית אתרים