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