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
  1. Home
  2. General Programming
  3. WPF
  4. Chat application in wpf using TCp/IP

Chat application in wpf using TCp/IP

Scheduled Pinned Locked Moved WPF
csharpwpfwcflounge
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.
  • J Offline
    J Offline
    JS 2008
    wrote on last edited by
    #1

    Need a chat application in wpf using TCP/IP service,not using wcf

    R 1 Reply Last reply
    0
    • J JS 2008

      Need a chat application in wpf using TCP/IP service,not using wcf

      R Offline
      R Offline
      Ray Cassick
      wrote on last edited by
      #2

      You having an issue doing it or just asking if anyone here has one they are willing to give? WPF does not really stop you form using raw sockets unless you are doing an XBAP, app and then you may need to adjust some security to allow it to work. Do you have a specific aversion to using WCF or do you have a hard requirement that you must use raw sockets.


      LinkedIn[^] | Blog[^] | Twitter[^]

      J 1 Reply Last reply
      0
      • R Ray Cassick

        You having an issue doing it or just asking if anyone here has one they are willing to give? WPF does not really stop you form using raw sockets unless you are doing an XBAP, app and then you may need to adjust some security to allow it to work. Do you have a specific aversion to using WCF or do you have a hard requirement that you must use raw sockets.


        LinkedIn[^] | Blog[^] | Twitter[^]

        J Offline
        J Offline
        JS 2008
        wrote on last edited by
        #3

        Listen PartSocket newsock = new Socket( AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp ); IPEndPoint iep = new IPEndPoint( IPAddress.Any, 2091 ); newsock.Bind( iep ); newsock.Listen( 5 ); newsock.BeginAccept( new AsyncCallback( AcceptConn ), newsock ); void AcceptConn( IAsyncResult iar ) { Socket oldserver = ( Socket )iar.AsyncState; client = oldserver.EndAccept( iar ); Thread receiver = new Thread( new ThreadStart( ReceiveData ) ); receiver.Start(); } void ReceiveData() { int recv; string stringData; while( true ) { recv = client.Receive( data ); stringData = Encoding.ASCII.GetString( data, 0, recv ); if( stringData == "bye" ) break; } stringData = "bye"; byte[] message = Encoding.ASCII.GetBytes( stringData ); client.Send( message ); client.Close(); return; } Connection client = new Socket( AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp ); IPEndPoint iep = new IPEndPoint( IPAddress.Parse( "127.10.27.61" ), 2091 ); client.BeginConnect( iep, new AsyncCallback( Connected ), client ); void Connected( IAsyncResult iar ) { client.EndConnect( iar ); Thread receiver = new Thread( new ThreadStart( ReceiveData ) ); receiver.Start(); } My code is like thisduring the connection part error happends,May be due to 2 threads,how can i solve the same

        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