By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,365 Members | 3,180 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,365 IT Pros & Developers. It's quick & easy.

Slow Transfer Rates on Socket and TCPClient data reads

P: n/a
I am writing a newsgroup client. I have the protocol figured out. But I
get slow transfer speeds off any of the network objects read the data from

For example one of the commands for a news client to use is "XOVER
articlenumber-"

This return string after string of all the news articles from article number
on....

Another newsclient, i wont name names, pulls data down just fine. Using a
"newsgroup header" accelerator that compresses the headers server side and
transmits then then uncompresses them and delivers them to the client I can
see exactly how much data is being download. They give the stats of data
transfer speed. This other program routinely gets speeds of greater than
1Mbps. It spikes up to 2Mbps and occassionally goes down to 0.5Mbps. When
I open a connection and issue the proper command to do the same I can see
via the accelerator that my data read speeds will rarely go over 0.5Mbps
and will actually however from 0.1 to 0.5Mbps for the life of the transfer.

I have tried many different ways. Using the NetworkStream and a
StreamReader object reading line by line off the stream. Reading bytes off
the Network Stream object, brought off the TCPClient object. Working
directly with the Socket object and not the TCPClient object. I have taken
out any and all extra processing that could be done off the received bytes
just to eliminate string comparisons etc off as a cause of the performance
problem.

I have tried it in VB.Net ... C# ... unmanaged C++ code all return the same
pitiful network transfer rates.

Following is a snippit of code I am using on the VB side to read data off
the stream.

Dim buffer(8000) As Byte
Dim se As SocketError
Dim iRx As Integer
Do While True
iRx = m_Socket.Receive(buffer, 0, buffer.Length, se)
Loop

I know this is an endless loop at this point but for my testing purposes
this is fine. There is plenty of data for me to get in the 50 million worth
of lines that this XOVER command is returning to me.

Here is some of the code from the class I am using to create the object.

Private m_Socket As New
System.Net.Sockets.Socket(AddressFamily.InterNetwo rk, SocketType.Stream,
ProtocolType.Tcp)
Private m_strHost As String
Private m_intPort As Integer

Property Host() As String
Get
Return m_strHost
End Get
Set(ByVal value As String)
m_strHost = value
End Set
End Property

Property Port() As Integer
Get
Return m_intPort
End Get
Set(ByVal value As Integer)
m_intPort = value
End Set
End Property

Public Function Connect() As Boolean
Dim ipAdd As IPAddress = Dns.GetHostEntry(m_strHost).AddressList(0)
Dim remoteEP As IPEndPoint = New IPEndPoint(ipAdd, m_intPort)
m_Socket.Connect(remoteEP)
Return True
End Function

I know I have no error handling in yet but am merely at the testing phase.
I do not know why at this point I have such pitiful transfer rates. I hope
someone can give me some type of idea. I can also share some of the other
methods I tried to use to read the data off the various different connection
methods I have tried. I am about to try with another language... it starts
with a j..... even though I really dont have any desire to use it :) Please
help

Thanks
Sep 30 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Well I wrote the same code in java. It fluctuates quite a bit transfer wise
but it goes from .5 to 3Mbps. Mostly staying between 1 and 2 Mbps...

I feel like I must not be doing someting in .Net to optimize my reads and
get the best speed. I would love it if someone could tell me what it si.

:/
"Andrew Jackson" <no email specifiedwrote in message
news:XY******************************@giganews.com ...
>I am writing a newsgroup client. I have the protocol figured out. But I
get slow transfer speeds off any of the network objects read the data from

For example one of the commands for a news client to use is "XOVER
articlenumber-"

This return string after string of all the news articles from article
number on....

Another newsclient, i wont name names, pulls data down just fine. Using a
"newsgroup header" accelerator that compresses the headers server side and
transmits then then uncompresses them and delivers them to the client I
can see exactly how much data is being download. They give the stats of
data transfer speed. This other program routinely gets speeds of greater
than 1Mbps. It spikes up to 2Mbps and occassionally goes down to 0.5Mbps.
When I open a connection and issue the proper command to do the same I can
see via the accelerator that my data read speeds will rarely go over
0.5Mbps and will actually however from 0.1 to 0.5Mbps for the life of the
transfer.

I have tried many different ways. Using the NetworkStream and a
StreamReader object reading line by line off the stream. Reading bytes
off the Network Stream object, brought off the TCPClient object. Working
directly with the Socket object and not the TCPClient object. I have
taken out any and all extra processing that could be done off the received
bytes just to eliminate string comparisons etc off as a cause of the
performance problem.

I have tried it in VB.Net ... C# ... unmanaged C++ code all return the
same pitiful network transfer rates.

Following is a snippit of code I am using on the VB side to read data off
the stream.

Dim buffer(8000) As Byte
Dim se As SocketError
Dim iRx As Integer
Do While True
iRx = m_Socket.Receive(buffer, 0, buffer.Length, se)
Loop

I know this is an endless loop at this point but for my testing purposes
this is fine. There is plenty of data for me to get in the 50 million
worth of lines that this XOVER command is returning to me.

Here is some of the code from the class I am using to create the object.

Private m_Socket As New
System.Net.Sockets.Socket(AddressFamily.InterNetwo rk, SocketType.Stream,
ProtocolType.Tcp)
Private m_strHost As String
Private m_intPort As Integer

Property Host() As String
Get
Return m_strHost
End Get
Set(ByVal value As String)
m_strHost = value
End Set
End Property

Property Port() As Integer
Get
Return m_intPort
End Get
Set(ByVal value As Integer)
m_intPort = value
End Set
End Property

Public Function Connect() As Boolean
Dim ipAdd As IPAddress = Dns.GetHostEntry(m_strHost).AddressList(0)
Dim remoteEP As IPEndPoint = New IPEndPoint(ipAdd, m_intPort)
m_Socket.Connect(remoteEP)
Return True
End Function

I know I have no error handling in yet but am merely at the testing phase.
I do not know why at this point I have such pitiful transfer rates. I
hope someone can give me some type of idea. I can also share some of the
other methods I tried to use to read the data off the various different
connection methods I have tried. I am about to try with another
language... it starts with a j..... even though I really dont have any
desire to use it :) Please help

Thanks

Sep 30 '07 #2

P: n/a
On Sun, 30 Sep 2007 14:17:57 -0400, "Andrew Jackson" <no email
specifiedwrote:
>
Following is a snippit of code I am using on the VB side to read data off
the stream.

Dim buffer(8000) As Byte
Dim se As SocketError
Dim iRx As Integer
Do While True
iRx = m_Socket.Receive(buffer, 0, buffer.Length, se)
Loop
Do you not have Option Strict set to On?

It looks to me like in VS2005 there is no overload of Socket.Receive
with the paramters you are specifying, and that the fourth argument
will be assumed to be a SocketFlags, not a SocketError.

I have no idea what effect if any that might have.
Sep 30 '07 #3

P: n/a
I will check it out... in the mean time I wrote some code that more closely
matches the code I wrote for java... It also runs slow as molasses. I have
tried to try to do these things in different ways. But like I said even
doing it with c++ I still get the same slow transfers.

Imports System.Net.Sockets
Imports System.IO
Module Module1
Dim socket As Socket = New
System.Net.Sockets.Socket(AddressFamily.InterNetwo rk, SocketType.Stream,
ProtocolType.Tcp)
Dim ns As NetworkStream
Dim sr As StreamReader
Dim sw As StreamWriter
Sub Main()
socket.Connect("localhost", 119)
ns = New NetworkStream(socket)
sr = New StreamReader(ns)
sw = New StreamWriter(ns)
ReadLine()
SendLine("AUTHINFO USER myusername")
ReadLine()
SendLine("AUTHINFO PASS mypassword")
ReadLine()
SendLine("GROUP alt.binaries.multimedia")
Dim strReturn As String = ReadLine()
Dim artCount As String = strReturn.Split(" ")(1)
Dim artFirst As String = strReturn.Split(" ")(2)
Dim artLast As String = strReturn.Split(" ")(3)
SendLine("XOVER " & artFirst & "-")
While True
ReadLine()
End While
End Sub
Public Sub SendLine(ByVal Text As String)
sw.Write(Text & vbCrLf)
sw.Flush()
End Sub
Public Function ReadLine() As String
Dim strLine As String
strLine = sr.ReadLine
Return strLine
End Function
End Module

The java code I wrote is the following:
import java.util.Scanner;
import java.io.*;
import java.net.*;
/**
* The HelloWorldApp class implements an application that
* simply prints "Hello World!" to standard output.
*/
class MySocket {
static Socket socket;
static PrintWriter out = null;
static BufferedReader in = null;
public static void main(String[] args) throws Exception
{
socket = new Socket("localhost", 119);
out = new PrintWriter(socket.getOutputStream(), true);
in = new BufferedReader(new InputStreamReader(socket.getInputStream()));

ReadLine();
SendLine("AUTHINFO USER myusername");
ReadLine();
SendLine("AUTHINFO PASS mypassword");
ReadLine();
SendLine("GROUP alt.binaries.multimedia");
String ret = ReadLine();
String artCount = ret.split(" ")[1];
String artFirst = ret.split(" ")[2];
String artLast = ret.split(" ")[3];
System.out.println(artCount);
System.out.println(artFirst);
System.out.println(artLast);
SendLine("XOVER " + artFirst + "-");
boolean flag=true;
while (flag) {
ReadLine();
}
}
public static void SendLine(String text) throws Exception
{
out.println(text);
}
public static String ReadLine() throws Exception
{
String line;
line = in.readLine();
return line;
}
}
"Jack Jackson" <ja********@pebbleridge.comwrote in message
news:it********************************@4ax.com...
On Sun, 30 Sep 2007 14:17:57 -0400, "Andrew Jackson" <no email
specifiedwrote:
>>
Following is a snippit of code I am using on the VB side to read data off
the stream.

Dim buffer(8000) As Byte
Dim se As SocketError
Dim iRx As Integer
Do While True
iRx = m_Socket.Receive(buffer, 0, buffer.Length, se)
Loop

Do you not have Option Strict set to On?

It looks to me like in VS2005 there is no overload of Socket.Receive
with the paramters you are specifying, and that the fourth argument
will be assumed to be a SocketFlags, not a SocketError.

I have no idea what effect if any that might have.

Sep 30 '07 #4

P: n/a
I made the correction still it doesnt make a difference.

Seems strange. I am getting about .1 to .3Mbps with this particular
Receive.

"Jack Jackson" <ja********@pebbleridge.comwrote in message
news:it********************************@4ax.com...
On Sun, 30 Sep 2007 14:17:57 -0400, "Andrew Jackson" <no email
specifiedwrote:
>>
Following is a snippit of code I am using on the VB side to read data off
the stream.

Dim buffer(8000) As Byte
Dim se As SocketError
Dim iRx As Integer
Do While True
iRx = m_Socket.Receive(buffer, 0, buffer.Length, se)
Loop

Do you not have Option Strict set to On?

It looks to me like in VS2005 there is no overload of Socket.Receive
with the paramters you are specifying, and that the fourth argument
will be assumed to be a SocketFlags, not a SocketError.

I have no idea what effect if any that might have.

Oct 1 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.