Results 1 to 2 of 2

Thread: TCP socket always returns TRUE on connected statement

Threaded View

  1. #1

    Thread Starter
    Frenzied Member Ultimasnake's Avatar
    Join Date
    Feb 2002
    Location
    Amsterdam, holland
    Posts
    1,172

    TCP socket always returns TRUE on connected statement

    Hello people i am currently writting myself an app where i need a tcp/ip connection Currently all is working except for one thing

    both the socket.connected, StreamReader.canread and StreamWriter.canwrite always return true even if my other app is totaly turned off and disconnected.......

    ofcourse this is rather odd and i am wondering if i did something wrong OR that there is a fix to all this :S

    Code:
    IPAddress localAddr = IPAddress.Parse("127.0.0.1");
    			ConnectionListener = new TcpListener(localAddr,port);
    			ConnectionListener.Start();
    			ConnectionClientSocket = ConnectionListener.AcceptSocket();
    			if(ConnectionClientSocket.Connected)
    			{
    				ConnectionListener.Stop();				
    				ConnectionStream = new NetworkStream(ConnectionClientSocket);
    				ConnectionReader = new StreamReader(ConnectionStream);
    				ConnectionWriter = new StreamWriter(ConnectionStream);
    
    				//RAISE
    				Connected();
    				//END RAISE
    
    				while(ConnectionStream.CanWrite && ConnectionStream.CanRead && ForceDisconnect == false)
    				{
    					readSocket();
    					ConnectionWriter.Flush();
    					System.Windows.Forms.Application.DoEvents();
    				}
    			}
    			doClose();
    this is just the "server" side part of the socket readSocket checks for packages from the client party and doClose() makes sure all controlls are closed and set to null again. But the code never even reaches it.

    (also the while loop contained ConnectionClientSocket.connected etc but this is the current thing i am trying)



    edit:
    If there is someone with a Fully 100% working socket for C# which doesn't need any non .net controls i am happy with that too :P
    Last edited by Ultimasnake; Jan 2nd, 2005 at 03:30 PM.
    For my PC and MS Smartphone 2003 software visit
    http://www.ultimasoftware.nl

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width