Unable to read data from the transport connection

G

Guest

Hi to all,

Im searching a hand to solve an Exception that i get when i try to give the
user to a gmail account...

Any help would be appreciated.. Thanks in advance

This is a piece of my code:

Server=new TcpClient("pop.gmail.com",995); //stablish a connection

Networkstream=Server.GetStream();//returns the first stream

Readerstream=new StreamReader(Server.GetStream());

username="(e-mail address removed)";
string Data= "USER "+username + CRLF;
byte[] Data_ = System.Text.Encoding.ASCII.GetBytes(Data.ToCharArray());
Networkstream.Write(Data_,0,Data_.Length);
string temp=read_single_line_response();


---------------------------
The stack trace is this:
---------------------------
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.IO.IOException: Unable to read data from the transport connection.
---> System.Net.Sockets.SocketException: Se ha forzado la interrupción de una
conexión existente por el host remoto
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32
size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset,
Int32 size)
--- End of inner exception stack trace ---
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset,
Int32 size)
at System.IO.StreamReader.ReadBuffer()
at System.IO.StreamReader.ReadLine()
at GmailParser.Emailer.read_single_line_response() in c:\documents and
settings\alpha1\escritorio\gmailparsers\emailer.cs:line 148
at GmailParser.Emailer.USER() in c:\documents and
settings\alpha1\escritorio\gmailparsers\emailer.cs:line 101
at GmailParser.Emailer.Connect() in c:\documents and
settings\alpha1\escritorio\gmailparsers\emailer.cs:line 50
at GmailParser.Form1.Form1_Load(Object sender, EventArgs e) in
C:\Documents and Settings\Alpha1\Escritorio\GmailParsers\Form1.cs:line 78
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windowss/microsoft.net/framework/v1.1.4322/mscorlib.dll
----------------------------------------
GmailParser
Assembly Version: 1.0.2173.39969
Win32 Version: 1.0.2173.39969
CodeBase:
file:///C:/Documents%20and%20Settings/Alpha1/Escritorio/GmailParsers/bin/Debug/GmailParser.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windowss/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll
----------------------------------------
System
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windowss/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
----------------------------------------
System.Drawing
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windowss/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll
----------------------------------------
System.Xml
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windowss/assembly/gac/system.xml/1.0.5000.0__b77a5c561934e089/system.xml.dll
----------------------------------------

************** JIT Debugging **************
To enable just in time (JIT) debugging, the config file for this
application or machine (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the machine
rather than being handled by this dialog.
 
V

Vadym Stetsyak

you can check stream CanRead property before reading from it
why do you create StreamReader? you can read directly from network stream

Also notice that StreamReader is inherited from TextReader and NetworkStream
from Stream

--
Vadym Stetsyak aka Vadmyst
http://vadmyst.blogspot.com

Josema said:
Hi to all,

Im searching a hand to solve an Exception that i get when i try to give
the
user to a gmail account...

Any help would be appreciated.. Thanks in advance

This is a piece of my code:

Server=new TcpClient("pop.gmail.com",995); //stablish a connection

Networkstream=Server.GetStream();//returns the first stream

Readerstream=new StreamReader(Server.GetStream());

username="(e-mail address removed)";
string Data= "USER "+username + CRLF;
byte[] Data_ =
System.Text.Encoding.ASCII.GetBytes(Data.ToCharArray());
Networkstream.Write(Data_,0,Data_.Length);
string temp=read_single_line_response();


---------------------------
The stack trace is this:
---------------------------
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.IO.IOException: Unable to read data from the transport connection.
---> System.Net.Sockets.SocketException: Se ha forzado la interrupcion de
una
conexion existente por el host remoto
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32
size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset,
Int32 size)
--- End of inner exception stack trace ---
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset,
Int32 size)
at System.IO.StreamReader.ReadBuffer()
at System.IO.StreamReader.ReadLine()
at GmailParser.Emailer.read_single_line_response() in c:\documents and
settings\alpha1\escritorio\gmailparsers\emailer.cs:line 148
at GmailParser.Emailer.USER() in c:\documents and
settings\alpha1\escritorio\gmailparsers\emailer.cs:line 101
at GmailParser.Emailer.Connect() in c:\documents and
settings\alpha1\escritorio\gmailparsers\emailer.cs:line 50
at GmailParser.Form1.Form1_Load(Object sender, EventArgs e) in
C:\Documents and Settings\Alpha1\Escritorio\GmailParsers\Form1.cs:line 78
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windowss/microsoft.net/framework/v1.1.4322/mscorlib.dll
----------------------------------------
GmailParser
Assembly Version: 1.0.2173.39969
Win32 Version: 1.0.2173.39969
CodeBase:
file:///C:/Documents%20and%20Settings/Alpha1/Escritorio/GmailParsers/bin/Debug/GmailParser.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windowss/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll
----------------------------------------
System
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windowss/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
----------------------------------------
System.Drawing
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windowss/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll
----------------------------------------
System.Xml
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windowss/assembly/gac/system.xml/1.0.5000.0__b77a5c561934e089/system.xml.dll
----------------------------------------

************** JIT Debugging **************
To enable just in time (JIT) debugging, the config file for this
application or machine (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the machine
rather than being handled by this dialog.
 
G

Guest

Thanks a lot Vadym, i will try first to use only Network Stream, and the Can
Read property...

--
Thanks
Regards.
Josema


Vadym Stetsyak said:
you can check stream CanRead property before reading from it
why do you create StreamReader? you can read directly from network stream

Also notice that StreamReader is inherited from TextReader and NetworkStream
from Stream

--
Vadym Stetsyak aka Vadmyst
http://vadmyst.blogspot.com

Josema said:
Hi to all,

Im searching a hand to solve an Exception that i get when i try to give
the
user to a gmail account...

Any help would be appreciated.. Thanks in advance

This is a piece of my code:

Server=new TcpClient("pop.gmail.com",995); //stablish a connection

Networkstream=Server.GetStream();//returns the first stream

Readerstream=new StreamReader(Server.GetStream());

username="(e-mail address removed)";
string Data= "USER "+username + CRLF;
byte[] Data_ =
System.Text.Encoding.ASCII.GetBytes(Data.ToCharArray());
Networkstream.Write(Data_,0,Data_.Length);
string temp=read_single_line_response();


---------------------------
The stack trace is this:
---------------------------
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.IO.IOException: Unable to read data from the transport connection.
---> System.Net.Sockets.SocketException: Se ha forzado la interrupcion de
una
conexion existente por el host remoto
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32
size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset,
Int32 size)
--- End of inner exception stack trace ---
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset,
Int32 size)
at System.IO.StreamReader.ReadBuffer()
at System.IO.StreamReader.ReadLine()
at GmailParser.Emailer.read_single_line_response() in c:\documents and
settings\alpha1\escritorio\gmailparsers\emailer.cs:line 148
at GmailParser.Emailer.USER() in c:\documents and
settings\alpha1\escritorio\gmailparsers\emailer.cs:line 101
at GmailParser.Emailer.Connect() in c:\documents and
settings\alpha1\escritorio\gmailparsers\emailer.cs:line 50
at GmailParser.Form1.Form1_Load(Object sender, EventArgs e) in
C:\Documents and Settings\Alpha1\Escritorio\GmailParsers\Form1.cs:line 78
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windowss/microsoft.net/framework/v1.1.4322/mscorlib.dll
----------------------------------------
GmailParser
Assembly Version: 1.0.2173.39969
Win32 Version: 1.0.2173.39969
CodeBase:
file:///C:/Documents%20and%20Settings/Alpha1/Escritorio/GmailParsers/bin/Debug/GmailParser.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windowss/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll
----------------------------------------
System
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windowss/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
----------------------------------------
System.Drawing
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windowss/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll
----------------------------------------
System.Xml
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase:
file:///c:/windowss/assembly/gac/system.xml/1.0.5000.0__b77a5c561934e089/system.xml.dll
----------------------------------------

************** JIT Debugging **************
To enable just in time (JIT) debugging, the config file for this
application or machine (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the machine
rather than being handled by this dialog.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top