473,322 Members | 1,480 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Slow Transfer Rates on Socket and TCPClient data reads

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
4 7541
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jim W | last post by:
This is a cross-post from the .NET group since it looks like it may not be ..NET. New information since the original post is that is the wireless network is enabled and connected the socket...
3
by: Daniel | last post by:
TcpClient close() method socket leak when i use TcpClient to open a connection, send data and close the TcpClient with myTcpClientInstance.Close(); it takes 60 seconds for the actual socket on...
11
by: ajou_king | last post by:
I was running some tests on my Win32 1GHZ processor to see how long it would take to transmit objects numerous times via TCP/IP using C# ..NET Remoting vs the C++ trustworthy method of binary...
3
by: Ricardo Quintanilla | last post by:
i had a problem whom i do not know how to explain. i was using a TcpClient (System.Net.Sockets.TcpClient) object to send and receive data to an AS400 socket. Two months ago it started to work...
3
by: Alessandro | last post by:
Hi all! I'm trying to write a file transfer application using TCP, but I'm having some problem to connect the client and the server. Sniffing with Ethereal I can see the packets sent from the...
13
by: coloradowebdev | last post by:
i am working on basically a proxy server that handles requests via remoting from clients and executes transactions against a third-party server via TCP. the remoting site works like a champ. my...
2
by: Bonzol | last post by:
vb.net 2003 Windows application We have a Client/Server system set up by communicating through a TCPClient object. The server loops continuously using a tcplistener device and each time a client...
3
by: Sir Psycho | last post by:
Hi, For some reason, when i step over this code, it returns the full byte stream im expecting from the server, however when I let it run with no intervention, it only seems to grab a small chunk...
1
by: Diego F. | last post by:
Hello. I'm having problems reading data from a socket. In my test, I see the maximum size to get data from the socket is 8192 bytes. In my tests, if I send less that 8192, the readen data have...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.