Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. TCP, channels, sockets sync or async ?

TCP, channels, sockets sync or async ?

Scheduled Pinned Locked Moved C#
sysadminquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nahumtakum
    wrote on last edited by
    #1

    Hi everyone! I want to write an application which has a server and some clients. I would like them to communicate with tcp/ip. I would like to send and recieve all kinds of data. I have read about TCPListener, TCPClient, channels, sockets sync and async methods. What are the diffrences between those methods ? Which is the better way ? Thanks.

    A 1 Reply Last reply
    0
    • N nahumtakum

      Hi everyone! I want to write an application which has a server and some clients. I would like them to communicate with tcp/ip. I would like to send and recieve all kinds of data. I have read about TCPListener, TCPClient, channels, sockets sync and async methods. What are the diffrences between those methods ? Which is the better way ? Thanks.

      A Offline
      A Offline
      Anonymous
      wrote on last edited by
      #2

      If your wanting to talk RAW TCP/IP - then use the Listner and either the client or socket class. Example: TcpListener tcplpop = new TcpListener(110); tcplpop.Start(); Socket s = tcplpop.AcceptSocket() // Blocks until someone calls s.Send(...) s.Receive(...)

      N 1 Reply Last reply
      0
      • A Anonymous

        If your wanting to talk RAW TCP/IP - then use the Listner and either the client or socket class. Example: TcpListener tcplpop = new TcpListener(110); tcplpop.Start(); Socket s = tcplpop.AcceptSocket() // Blocks until someone calls s.Send(...) s.Receive(...)

        N Offline
        N Offline
        nahumtakum
        wrote on last edited by
        #3

        What is the difference between version no.1: TcpListener tcplpop = new TcpListener(110); tcplpop.Start(); Socket s = tcplpop.AcceptSocket() // Blocks until someone calls s.Send(...) s.Receive(...) and version no.2: IPEndPoint dbg_EndPoint = new IPEndPoint(ipAddress, dbg_port); Socket dbg_listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp ); dbg_listener.Bind(dbg_EndPoint); dbg_listener.Listen(num_of_devices); dbg_listener.BeginAccept( new AsyncCallback(AcceptCallback), dbg_listener ); // Get the socket that handles the client request. Socket listener = (Socket) ar.AsyncState; Socket handler = listener.EndAccept(ar); // Create the state object. StateObject state = new StateObject(); state.workSocket = handler; handler.BeginReceive( state.buffer, 0, StateObject.BufferSize, 0, new AsyncCallback(ReadCallback), state); Thanks.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups