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. Visual Basic
  4. An existing connection was forcibly closed by the remote host? [modified]

An existing connection was forcibly closed by the remote host? [modified]

Scheduled Pinned Locked Moved Visual Basic
helpsysadminmcpquestion
3 Posts 3 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.
  • A Offline
    A Offline
    AliAmjad
    wrote on last edited by
    #1

    Previously my code was working perfectly fine but suddenly showing up this error Unable to write data to the transport connection:An existing connection was forcibly closed by the remote host; whenever i try to write something on the network stream. Following is the code i am using right now:

     Dim PacketSize As Integer = 8192
    
            Dim client As New TcpClient
            client.Connect(IPAddress.Parse("192.168.15.51"), 7771)
    
            Dim ns As NetworkStream = client.GetStream
    
            Dim fs As New FileStream(FileName, FileMode.Open, FileAccess.Read)
    
            Dim buffer(PacketSize - 1) As Byte
    
            Dim i As Integer
            i = fs.Read(buffer, 0, PacketSize)
    
            While i <> 0
    
                ns.Write(buffer, 0, i) <-- this line cause the error
    
                i = fs.Read(buffer, 0, PacketSize)
    
            End While
    
    
            fs.Close()
            ns.Close()
    

    There's no anti-virus or firewall on target machine. I've even turned window's firewall off. Do i have to start any service on the target machine which somehow stopped??? I've searched everywhere but didn't find solution. Please help.

    AliAmjad(MCP) First make it Run THEN make it Run Fast!

    modified on Tuesday, May 5, 2009 2:13 AM

    D D 2 Replies Last reply
    0
    • A AliAmjad

      Previously my code was working perfectly fine but suddenly showing up this error Unable to write data to the transport connection:An existing connection was forcibly closed by the remote host; whenever i try to write something on the network stream. Following is the code i am using right now:

       Dim PacketSize As Integer = 8192
      
              Dim client As New TcpClient
              client.Connect(IPAddress.Parse("192.168.15.51"), 7771)
      
              Dim ns As NetworkStream = client.GetStream
      
              Dim fs As New FileStream(FileName, FileMode.Open, FileAccess.Read)
      
              Dim buffer(PacketSize - 1) As Byte
      
              Dim i As Integer
              i = fs.Read(buffer, 0, PacketSize)
      
              While i <> 0
      
                  ns.Write(buffer, 0, i) <-- this line cause the error
      
                  i = fs.Read(buffer, 0, PacketSize)
      
              End While
      
      
              fs.Close()
              ns.Close()
      

      There's no anti-virus or firewall on target machine. I've even turned window's firewall off. Do i have to start any service on the target machine which somehow stopped??? I've searched everywhere but didn't find solution. Please help.

      AliAmjad(MCP) First make it Run THEN make it Run Fast!

      modified on Tuesday, May 5, 2009 2:13 AM

      D Offline
      D Offline
      Dinesh Vitharana
      wrote on last edited by
      #2

      http://social.msdn.microsoft.com/forums/en-US/netfxnetcom/thread/6981b252-30f0-4eb9-a3a6-bf6f2b138fb3/ Visit this. dinvit83

      1 Reply Last reply
      0
      • A AliAmjad

        Previously my code was working perfectly fine but suddenly showing up this error Unable to write data to the transport connection:An existing connection was forcibly closed by the remote host; whenever i try to write something on the network stream. Following is the code i am using right now:

         Dim PacketSize As Integer = 8192
        
                Dim client As New TcpClient
                client.Connect(IPAddress.Parse("192.168.15.51"), 7771)
        
                Dim ns As NetworkStream = client.GetStream
        
                Dim fs As New FileStream(FileName, FileMode.Open, FileAccess.Read)
        
                Dim buffer(PacketSize - 1) As Byte
        
                Dim i As Integer
                i = fs.Read(buffer, 0, PacketSize)
        
                While i <> 0
        
                    ns.Write(buffer, 0, i) <-- this line cause the error
        
                    i = fs.Read(buffer, 0, PacketSize)
        
                End While
        
        
                fs.Close()
                ns.Close()
        

        There's no anti-virus or firewall on target machine. I've even turned window's firewall off. Do i have to start any service on the target machine which somehow stopped??? I've searched everywhere but didn't find solution. Please help.

        AliAmjad(MCP) First make it Run THEN make it Run Fast!

        modified on Tuesday, May 5, 2009 2:13 AM

        D Offline
        D Offline
        daveice
        wrote on last edited by
        #3

        I got exactly the same problem. this app used to works well....

        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