Showing posts with label tcpclient. Show all posts
Showing posts with label tcpclient. Show all posts

Tuesday, March 13, 2012

TCPClient App Question

I wonder if anyone could give me a suggestion on how to best handle this
scenario.
I wish to have an aspx page contact a server and receive messages.
Initially, a login messge is sent, then after being validated, a second
message is sent which contains data to complete a stock market trade. The
server then should respond not only once, but with several return messages.
So far all I have found are examples that send, receive, and disconnect,
which I have working. However, since all returning data to the client should
be in response to the order submitted, I cannot simply continue to resend
the original data for the trade. I need to keep the connection open and the
grab all incoming messages until the client quits.
Could anyone suggest how I should modfy the following code to keep the
connection open and continue to rceive subsequent messages?
static void Connect(String server, String message)
{
try
{
// Create a TcpClient.
// Note, for this client to work you need to have a TcpServer
// connected to the same address as specified by the server, port
// combination.
Int32 port = 13000;
TcpClient client = new TcpClient(server, port);
// Translate the passed message into ASCII and store it as a Byte array.
Byte[] data = System.Text.Encoding.ASCII.GetBytes(message);
// Get a client stream for reading and writing.
// Stream stream = client.GetStream();
NetworkStream stream = client.GetStream();
// Send the message to the connected TcpServer.
stream.Write(data, 0, data.Length);
Console.WriteLine("Sent: {0}", message);
// Receive the TcpServer.response.
// Buffer to store the response bytes.
data = new Byte[256];
// String to store the response ASCII representation.
String responseData = String.Empty;
// Read the first batch of the TcpServer response bytes.
Int32 bytes = stream.Read(data, 0, data.Length);
responseData = System.Text.Encoding.ASCII.GetString(data, 0, bytes);
Console.WriteLine("Received: {0}", responseData);
// Close everything.
client.Close();
}
catch (ArgumentNullException e)
{
Console.WriteLine("ArgumentNullException: {0}", e);
}
catch (SocketException e)
{
Console.WriteLine("SocketException: {0}", e);
}
Console.WriteLine("\n Press Enter to continue...");
Console.Read();
}try doing something like this:
while(true)
{
NetworkStream stream = client.GetStream();
...
...
...
Console.WriteLine("Received: {0}", responseData);
}
client.Close();

TCPClient connect slow only on XP Pro ASP on some boxes

I have an ASP.NET app that has very slow connect times using TCPClient, or
the Socket class, or even calling a COM object that uses C socket calls on
certain similar XP SP2 boxes.

On those boxes, if another connection is made within a couple seconds, it is
fast. Running the same C# code in a console app connects instantly.
Unplugging the network cable allows localhost connections to be instant (?!).

Running the same ASP.NET app on W2K or another XP Pro SP2 box is instant, so
it comes down to being ASP.NET on XP Pro on certain boxes. I've includes the
test results and programs. The boxes with the problems are laptops. Is it
an ASP.NET config issue? XP SP2 Security issue? Any ideas/help is greatly
appreciated.

Jim W

Test results:
XPPro ASP to Remote server
First took 6 seconds
Short sleep 1 took 0 seconds
Short sleep 2 took 0 seconds
Long sleep 1 took 4 seconds
Med sleep 2 took 0 seconds

XPPro ASP to Localhost with network connection
First took 6 seconds
Short sleep 1 took 0 seconds
Short sleep 2 took 0 seconds
Long sleep 1 took 4 seconds
Mec sleep 2 took 4 seconds

XPPro ASP to Localhost unplugged
First took 0 seconds
Short sleep 1 took 0 seconds
Short sleep 2 took 0 seconds
Long sleep 1 took 0 seconds
Med sleep 2 took 0 seconds

XPPro .NET console app to localhost, or remote
First took 0 seconds
Short sleep 1 took 0 seconds
Short sleep 2 took 0 seconds
Long sleep 1 took 0 seconds
Med sleep 2 took 0 seconds

W2K Server to local host, or remote
First took 0 seconds
Short sleep 1 took 0 seconds
Short sleep 2 took 0 seconds
Long sleep 1 took 0 seconds
Med sleep 2 took 0 seconds

Pertinent ASP.NET code behind:
...
private void RunTests_Click(object sender, System.EventArgs e)
{
Output.Text = Tester.RunTests( HostName.Text, "<br>" );
}

Pertinent .NET console app code.
...
static void Main(string[] args)
{
System.Console.WriteLine( SocketTest.Tester.RunTests( args[0], "\n" ) );
}

The tester called by ASP.NET and a .NET console app:

using System;
using System.Net;
using System.Net.Sockets;

namespace SocketTest
{
public class Tester
{
public Tester() {}

public static string RunTests( string server, string eol )
{
string ret = RunTest( server, "First ", eol );

System.Threading.Thread.Sleep( 100 );

ret += RunTest( server, "Short sleep 1", eol );

System.Threading.Thread.Sleep( 100 );

ret += RunTest( server, "Short sleep 2", eol );

System.Threading.Thread.Sleep( 10000 );

ret += RunTest( server, "Long sleep 1", eol );

System.Threading.Thread.Sleep( 5000 );

ret += RunTest( server, "Med sleep 2", eol );

return ret;
}

static string RunTest( string server, string prefix, string eol )
{
DateTime start = DateTime.Now;
TcpClient conn = new TcpClient( server, 80 );
TimeSpan span = DateTime.Now - start;
conn.Close();

return prefix + " took " + span.Seconds + " seconds " + eol;
}
}
}most likely you proxy server setting don't exclude localhost.

-- bruce (sqlwork.com)

"Jim W" <JimW@.discussions.microsoft.com> wrote in message
news:5F733251-4CAF-4EF9-98AA-0CA14F103854@.microsoft.com...
> I have an ASP.NET app that has very slow connect times using TCPClient, or
> the Socket class, or even calling a COM object that uses C socket calls on
> certain similar XP SP2 boxes.
> On those boxes, if another connection is made within a couple seconds, it
is
> fast. Running the same C# code in a console app connects instantly.
> Unplugging the network cable allows localhost connections to be instant
(?!).
>
> Running the same ASP.NET app on W2K or another XP Pro SP2 box is instant,
so
> it comes down to being ASP.NET on XP Pro on certain boxes. I've includes
the
> test results and programs. The boxes with the problems are laptops. Is
it
> an ASP.NET config issue? XP SP2 Security issue? Any ideas/help is
greatly
> appreciated.
> Jim W
> Test results:
> XPPro ASP to Remote server
> First took 6 seconds
> Short sleep 1 took 0 seconds
> Short sleep 2 took 0 seconds
> Long sleep 1 took 4 seconds
> Med sleep 2 took 0 seconds
> XPPro ASP to Localhost with network connection
> First took 6 seconds
> Short sleep 1 took 0 seconds
> Short sleep 2 took 0 seconds
> Long sleep 1 took 4 seconds
> Mec sleep 2 took 4 seconds
> XPPro ASP to Localhost unplugged
> First took 0 seconds
> Short sleep 1 took 0 seconds
> Short sleep 2 took 0 seconds
> Long sleep 1 took 0 seconds
> Med sleep 2 took 0 seconds
> XPPro .NET console app to localhost, or remote
> First took 0 seconds
> Short sleep 1 took 0 seconds
> Short sleep 2 took 0 seconds
> Long sleep 1 took 0 seconds
> Med sleep 2 took 0 seconds
> W2K Server to local host, or remote
> First took 0 seconds
> Short sleep 1 took 0 seconds
> Short sleep 2 took 0 seconds
> Long sleep 1 took 0 seconds
> Med sleep 2 took 0 seconds
> Pertinent ASP.NET code behind:
> ...
> private void RunTests_Click(object sender, System.EventArgs e)
> {
> Output.Text = Tester.RunTests( HostName.Text, "<br>" );
> }
> Pertinent .NET console app code.
> ...
> static void Main(string[] args)
> {
> System.Console.WriteLine( SocketTest.Tester.RunTests( args[0], "\n" ) );
> }
> The tester called by ASP.NET and a .NET console app:
> using System;
> using System.Net;
> using System.Net.Sockets;
> namespace SocketTest
> {
> public class Tester
> {
> public Tester() {}
> public static string RunTests( string server, string eol )
> {
> string ret = RunTest( server, "First ", eol );
> System.Threading.Thread.Sleep( 100 );
> ret += RunTest( server, "Short sleep 1", eol );
> System.Threading.Thread.Sleep( 100 );
> ret += RunTest( server, "Short sleep 2", eol );
> System.Threading.Thread.Sleep( 10000 );
> ret += RunTest( server, "Long sleep 1", eol );
> System.Threading.Thread.Sleep( 5000 );
> ret += RunTest( server, "Med sleep 2", eol );
> return ret;
> }
> static string RunTest( string server, string prefix, string eol )
> {
> DateTime start = DateTime.Now;
> TcpClient conn = new TcpClient( server, 80 );
> TimeSpan span = DateTime.Now - start;
> conn.Close();
> return prefix + " took " + span.Seconds + " seconds " + eol;
> }
> }
> }
Tx for the reply. I can't find any IIS proxy settings, can you give some
details? I'm not using a proxy in the IE settings. I did try turning the
proxy on, and excluded localhost, and it still is slow.

"bruce barker" wrote:

> most likely you proxy server setting don't exclude localhost.
> -- bruce (sqlwork.com)
New information. The slow computers have a gigbit network and wireless. If
the network cable is attached, *and* wireless is connected, the connect time
goes from 6 seconds (with just the network) to 27 seconds!
Jim,

We're experiencing (in a somewhat different context) the exactsame problem. We're as clueless as you seem to be. I can'treally relate to the suggestion that your proxy settings mighthave something to do with it, but who knows. Have you made anyprogress towards resolution since you posted your question?

Andre

> I have an ASP.NET app that has very slow connect times usingTCPClient, or
> the Socket class, or even calling a COM object that uses Csocket calls on
> certain similar XP SP2 boxes.
> On those boxes, if another connection is made within a coupleseconds, it is
> fast. Running the same C# code in a console app connectsinstantly.
> Unplugging the network cable allows localhost connections to beinstant (?!).
>
> Running the same ASP.NET app on W2K or another XP Pro SP2 boxis instant, so
> it comes down to being ASP.NET on XP Pro on certain boxes. I've includes the
> test results and programs. The boxes with the problems arelaptops. Is it
> an ASP.NET config issue? XP SP2 Security issue? Anyideas/help is greatly
> appreciated.
> Jim W
> Test results:
> XPPro ASP to Remote server
> First took 6 seconds
> Short sleep 1 took 0 seconds
> Short sleep 2 took 0 seconds
> Long sleep 1 took 4 seconds
> Med sleep 2 took 0 seconds
> XPPro ASP to Localhost with network connection
> First took 6 seconds
> Short sleep 1 took 0 seconds
> Short sleep 2 took 0 seconds
> Long sleep 1 took 4 seconds
> Mec sleep 2 took 4 seconds
> XPPro ASP to Localhost unplugged
> First took 0 seconds
> Short sleep 1 took 0 seconds
> Short sleep 2 took 0 seconds
> Long sleep 1 took 0 seconds
> Med sleep 2 took 0 seconds
> XPPro .NET console app to localhost, or remote
> First took 0 seconds
> Short sleep 1 took 0 seconds
> Short sleep 2 took 0 seconds
> Long sleep 1 took 0 seconds
> Med sleep 2 took 0 seconds
> W2K Server to local host, or remote
> First took 0 seconds
> Short sleep 1 took 0 seconds
> Short sleep 2 took 0 seconds
> Long sleep 1 took 0 seconds
> Med sleep 2 took 0 seconds
> Pertinent ASP.NET code behind:
> ...
> private void RunTests_Click(object sender, System.EventArgs e)
> {
> Output.Text = Tester.RunTests( HostName.Text, "<br>" );
> }
> Pertinent .NET console app code.
> ...
> static void Main(string[] args)
> {
> System.Console.WriteLine( SocketTest.Tester.RunTests( args[0],"\n" ) );
> }
> The tester called by ASP.NET and a .NET console app:
> using System;
> using System.Net;
> using System.Net.Sockets;
> namespace SocketTest
> {
> public class Tester
> {
> public Tester() {}
> public static string RunTests( string server, string eol )
> {
> string ret = RunTest( server, "First ", eol );
> System.Threading.Thread.Sleep( 100 );
>
> ret += RunTest( server, "Short sleep 1", eol );
> System.Threading.Thread.Sleep( 100 );
>
> ret += RunTest( server, "Short sleep 2", eol );
> System.Threading.Thread.Sleep( 10000 );
>
> ret += RunTest( server, "Long sleep 1", eol );
> System.Threading.Thread.Sleep( 5000 );
>
> ret += RunTest( server, "Med sleep 2", eol );
> return ret;
> }
> static string RunTest( string server, string prefix, stringeol )
> {
> DateTime start = DateTime.Now;
> TcpClient conn = new TcpClient( server, 80 );
> TimeSpan span = DateTime.Now - start;
> conn.Close();
> return prefix + " took " + span.Seconds + " seconds " +eol;
> }
> }
> }
User submitted from AEWNET (http://www.aewnet.com/)
No, I haven't found a solution. On the production machines, which are not
multihomed, it is not an issue, but it's on my todo list.

I will post if I find a solution. Please post if you find one.

"Andre de Lange" wrote:

> Jim,
> We're experiencing (in a somewhat different context) the exact same problem. We're as clueless as you seem to be. I can't really relate to the suggestion that your proxy settings might have something to do with it, but who knows. Have you made any progress towards resolution since you posted your question?
> Andre

TcpClient connection in app_code fails to work

Hello,

I am just getting into asp.net development (have a winforms background)

I have a sockets server running on my windows 2003 machine. I made a class called ClientTcp that opens a new connection and sends a string to the server and placed this in APP_CODE.

I call ClientTcp :

public class ClientTCP{private TcpClient tcpClient;public void SendData(String toSend) { tcpClient =new TcpClient(CONNECT_ADDR, CONNECT_PORT); NetworkStream networkStream = tcpClient.GetStream(); StreamWriter streamWriter =new StreamWriter(networkStream, System.Text.Encoding.ASCII); streamWriter.WriteLine(toSend); streamWriter.Flush(); }}

From my code behind Default.aspx.cs:

ClientTCP c =new ClientTCP();c.SendData("In app_code");

This works great on my local VS 2005 debug but when this runs under IIS 6 on Windows 2003 no data is received by the socket server.

Is there some sort of permissions issue or scope issue with using a class in APP_CODE


Interesting enough if I place the SendData method directly in the Default.aspx.cs file then it opens a socket connection and sends the data.

I have looked around for clues but could not find out why the socket wont connect and send by calling a code behind.

Thanks

I have solved this isssue.

I didn't post the complete method in my earlier post. This code works correctly.

My issue was that I was attempting to build an XmlDocument and then converting that to a string and sending that string over the stream.

It seems that I cannot create an XmlDocument in memory under IIS6. Creating a temporary file and then using this may solve the real issue but I have worked around this by building a custom string builder to generate xml compliant strings.

Thanks


TCPClient connect slow only on XP Pro ASP on some boxes

I have an ASP.NET app that has very slow connect times using TCPClient, or
the Socket class, or even calling a COM object that uses C socket calls on
certain similar XP SP2 boxes.
On those boxes, if another connection is made within a couple seconds, it is
fast. Running the same C# code in a console app connects instantly.
Unplugging the network cable allows localhost connections to be instant (?!)
.
Running the same ASP.NET app on W2K or another XP Pro SP2 box is instant, so
it comes down to being ASP.NET on XP Pro on certain boxes. I've includes th
e
test results and programs. The boxes with the problems are laptops. Is it
an ASP.NET config issue? XP SP2 Security issue? Any ideas/help is greatly
appreciated.
Jim W
Test results:
XPPro ASP to Remote server
First took 6 seconds
Short sleep 1 took 0 seconds
Short sleep 2 took 0 seconds
Long sleep 1 took 4 seconds
Med sleep 2 took 0 seconds
XPPro ASP to Localhost with network connection
First took 6 seconds
Short sleep 1 took 0 seconds
Short sleep 2 took 0 seconds
Long sleep 1 took 4 seconds
Mec sleep 2 took 4 seconds
XPPro ASP to Localhost unplugged
First took 0 seconds
Short sleep 1 took 0 seconds
Short sleep 2 took 0 seconds
Long sleep 1 took 0 seconds
Med sleep 2 took 0 seconds
XPPro .NET console app to localhost, or remote
First took 0 seconds
Short sleep 1 took 0 seconds
Short sleep 2 took 0 seconds
Long sleep 1 took 0 seconds
Med sleep 2 took 0 seconds
W2K Server to local host, or remote
First took 0 seconds
Short sleep 1 took 0 seconds
Short sleep 2 took 0 seconds
Long sleep 1 took 0 seconds
Med sleep 2 took 0 seconds
Pertinent ASP.NET code behind:
...
private void RunTests_Click(object sender, System.EventArgs e)
{
Output.Text = Tester.RunTests( HostName.Text, "<br>" );
}
Pertinent .NET console app code.
...
static void Main(string[] args)
{
System.Console.WriteLine( SocketTest.Tester.RunTests( args[0], "\n" ) );
}
The tester called by ASP.NET and a .NET console app:
using System;
using System.Net;
using System.Net.Sockets;
namespace SocketTest
{
public class Tester
{
public Tester() {}
public static string RunTests( string server, string eol )
{
string ret = RunTest( server, "First ", eol );
System.Threading.Thread.Sleep( 100 );
ret += RunTest( server, "Short sleep 1", eol );
System.Threading.Thread.Sleep( 100 );
ret += RunTest( server, "Short sleep 2", eol );
System.Threading.Thread.Sleep( 10000 );
ret += RunTest( server, "Long sleep 1", eol );
System.Threading.Thread.Sleep( 5000 );
ret += RunTest( server, "Med sleep 2", eol );
return ret;
}
static string RunTest( string server, string prefix, string eol )
{
DateTime start = DateTime.Now;
TcpClient conn = new TcpClient( server, 80 );
TimeSpan span = DateTime.Now - start;
conn.Close();
return prefix + " took " + span.Seconds + " seconds " + eol;
}
}
}most likely you proxy server setting don't exclude localhost.
-- bruce (sqlwork.com)
"Jim W" <JimW@.discussions.microsoft.com> wrote in message
news:5F733251-4CAF-4EF9-98AA-0CA14F103854@.microsoft.com...
> I have an ASP.NET app that has very slow connect times using TCPClient, or
> the Socket class, or even calling a COM object that uses C socket calls on
> certain similar XP SP2 boxes.
> On those boxes, if another connection is made within a couple seconds, it
is
> fast. Running the same C# code in a console app connects instantly.
> Unplugging the network cable allows localhost connections to be instant
(?!).
>
> Running the same ASP.NET app on W2K or another XP Pro SP2 box is instant,
so
> it comes down to being ASP.NET on XP Pro on certain boxes. I've includes
the
> test results and programs. The boxes with the problems are laptops. Is
it
> an ASP.NET config issue? XP SP2 Security issue? Any ideas/help is
greatly
> appreciated.
> Jim W
> Test results:
> XPPro ASP to Remote server
> First took 6 seconds
> Short sleep 1 took 0 seconds
> Short sleep 2 took 0 seconds
> Long sleep 1 took 4 seconds
> Med sleep 2 took 0 seconds
> XPPro ASP to Localhost with network connection
> First took 6 seconds
> Short sleep 1 took 0 seconds
> Short sleep 2 took 0 seconds
> Long sleep 1 took 4 seconds
> Mec sleep 2 took 4 seconds
> XPPro ASP to Localhost unplugged
> First took 0 seconds
> Short sleep 1 took 0 seconds
> Short sleep 2 took 0 seconds
> Long sleep 1 took 0 seconds
> Med sleep 2 took 0 seconds
> XPPro .NET console app to localhost, or remote
> First took 0 seconds
> Short sleep 1 took 0 seconds
> Short sleep 2 took 0 seconds
> Long sleep 1 took 0 seconds
> Med sleep 2 took 0 seconds
> W2K Server to local host, or remote
> First took 0 seconds
> Short sleep 1 took 0 seconds
> Short sleep 2 took 0 seconds
> Long sleep 1 took 0 seconds
> Med sleep 2 took 0 seconds
> Pertinent ASP.NET code behind:
> ...
> private void RunTests_Click(object sender, System.EventArgs e)
> {
> Output.Text = Tester.RunTests( HostName.Text, "<br>" );
> }
> Pertinent .NET console app code.
> ...
> static void Main(string[] args)
> {
> System.Console.WriteLine( SocketTest.Tester.RunTests( args[0], "\n" ) );
> }
> The tester called by ASP.NET and a .NET console app:
> using System;
> using System.Net;
> using System.Net.Sockets;
> namespace SocketTest
> {
> public class Tester
> {
> public Tester() {}
> public static string RunTests( string server, string eol )
> {
> string ret = RunTest( server, "First ", eol );
> System.Threading.Thread.Sleep( 100 );
> ret += RunTest( server, "Short sleep 1", eol );
> System.Threading.Thread.Sleep( 100 );
> ret += RunTest( server, "Short sleep 2", eol );
> System.Threading.Thread.Sleep( 10000 );
> ret += RunTest( server, "Long sleep 1", eol );
> System.Threading.Thread.Sleep( 5000 );
> ret += RunTest( server, "Med sleep 2", eol );
> return ret;
> }
> static string RunTest( string server, string prefix, string eol )
> {
> DateTime start = DateTime.Now;
> TcpClient conn = new TcpClient( server, 80 );
> TimeSpan span = DateTime.Now - start;
> conn.Close();
> return prefix + " took " + span.Seconds + " seconds " + eol;
> }
> }
> }
>
Tx for the reply. I can't find any IIS proxy settings, can you give some
details? I'm not using a proxy in the IE settings. I did try turning the
proxy on, and excluded localhost, and it still is slow.
"bruce barker" wrote:

> most likely you proxy server setting don't exclude localhost.
> -- bruce (sqlwork.com)
>
New information. The slow computers have a gigbit network and wireless. If
the network cable is attached, *and* wireless is connected, the connect time
goes from 6 seconds (with just the network) to 27 seconds!
Jim,
We're experiencing (in a somewhat different context) the exact=
same problem. We're as clueless as you seem to be. I can't=
really relate to the suggestion that your proxy settings might=
have something to do with it, but who knows. Have you made any=
progress towards resolution since you posted your question?
Andre

> I have an ASP.NET app that has very slow connect times using=
TCPClient, or
> the Socket class, or even calling a COM object that uses C=
socket calls on
> certain similar XP SP2 boxes.
> On those boxes, if another connection is made within a couple=
seconds, it is
> fast. Running the same C# code in a console app connects=
instantly.
> Unplugging the network cable allows localhost connections to be=
instant (?!).
>
> Running the same ASP.NET app on W2K or another XP Pro SP2 box=
is instant, so
> it comes down to being ASP.NET on XP Pro on certain boxes. =
I've includes the
> test results and programs. The boxes with the problems are=
laptops. Is it
> an ASP.NET config issue? XP SP2 Security issue? Any=
ideas/help is greatly
> appreciated.
> Jim W
> Test results:
> XPPro ASP to Remote server
> First took 6 seconds
> Short sleep 1 took 0 seconds
> Short sleep 2 took 0 seconds
> Long sleep 1 took 4 seconds
> Med sleep 2 took 0 seconds
> XPPro ASP to Localhost with network connection
> First took 6 seconds
> Short sleep 1 took 0 seconds
> Short sleep 2 took 0 seconds
> Long sleep 1 took 4 seconds
> Mec sleep 2 took 4 seconds
> XPPro ASP to Localhost unplugged
> First took 0 seconds
> Short sleep 1 took 0 seconds
> Short sleep 2 took 0 seconds
> Long sleep 1 took 0 seconds
> Med sleep 2 took 0 seconds
> XPPro .NET console app to localhost, or remote
> First took 0 seconds
> Short sleep 1 took 0 seconds
> Short sleep 2 took 0 seconds
> Long sleep 1 took 0 seconds
> Med sleep 2 took 0 seconds
> W2K Server to local host, or remote
> First took 0 seconds
> Short sleep 1 took 0 seconds
> Short sleep 2 took 0 seconds
> Long sleep 1 took 0 seconds
> Med sleep 2 took 0 seconds =09
> Pertinent ASP.NET code behind:
> ...
> private void RunTests_Click(object sender, System.EventArgs e)
> {
> =09Output.Text =3D Tester.RunTests( HostName.Text, "<br>" );
> }
> Pertinent .NET console app code.
> ...
> static void Main(string[] args)
> {
> =09System.Console.WriteLine( SocketTest.Tester.RunTests( args[0],=
"\n" ) );
> }
> The tester called by ASP.NET and a .NET console app:
> using System;
> using System.Net;
> using System.Net.Sockets;
> namespace SocketTest
> {
> =09public class Tester
> =09{
> =09=09public Tester() {}
> =09=09public static string RunTests( string server, string eol )
> =09=09{
> =09=09=09string ret =3D RunTest( server, "First ", eol );
> =09=09=09System.Threading.Thread.Sleep( 100 );
> =09=09=09
> =09=09=09ret +=3D RunTest( server, "Short sleep 1", eol );
> =09=09=09System.Threading.Thread.Sleep( 100 );
> =09=09=09
> =09=09=09ret +=3D RunTest( server, "Short sleep 2", eol );
> =09=09=09System.Threading.Thread.Sleep( 10000 );
> =09=09=09
> =09=09=09ret +=3D RunTest( server, "Long sleep 1", eol );
> =09=09=09System.Threading.Thread.Sleep( 5000 );
> =09=09=09
> =09=09=09ret +=3D RunTest( server, "Med sleep 2", eol );
> =09=09=09return ret;
> =09=09}
> =09=09static string RunTest( string server, string prefix, string=
eol )
> =09=09{
> =09=09=09DateTime start =3D DateTime.Now;
> =09=09=09TcpClient conn =3D new TcpClient( server, 80 );
> =09=09=09TimeSpan span =3D DateTime.Now - start;
> =09=09=09conn.Close();
> =09=09=09return prefix + " took " + span.Seconds + " seconds " +=
eol;
> =09=09}
> =09}
> }
>
User submitted from AEWNET (http://www.aewnet.com/)
No, I haven't found a solution. On the production machines, which are not
multihomed, it is not an issue, but it's on my todo list.
I will post if I find a solution. Please post if you find one.
"Andre de Lange" wrote:

> Jim,
> We're experiencing (in a somewhat different context) the exact same problem. We're
as clueless as you seem to be. I can't really relate to the suggestion that your pr
oxy settings might have something to do with it, but who knows. Have you made any pr
ogr
ess towards resolution since you posted your question?
> Andre

tcpclient socket webrequest

tcpclient socket webrequest

what are each used for? I read some reference books and did some research on
the internet, but I'm still confused.
could someone clarify this for me?

Thanks,
AaronHi Aaron,

Basically, you're lloking at similar types of classes for different levels
of network communication.

A Socket is a class for any type of network connection. It is a low-level,
generic class for sending and receiving data over a network, and can work
with virtually any type of protocol.

A TCPClient is a higher-level class for working with the TCP protocol. It
has a Socket (protected Client property) that does the actual connection,
and has properties and methods for communicating via the TCP protocol.

A WebRequest is a higher-level class for sending an HTTP Request over a TCP
connection. It contains properties and methods for sending an HTTP Request,
as well as properties and methods for receiving the HTTP Response that comes
back.

These are an excellent example of how Microsoft provides programming tools
of virtually any level necessary to perform development tasks. For example,
you could write your own TCP Client class by creating a class that uses a
Socket to connect to a TCP port. You could further extend that class by
creating a class that sends an HTTP Request and listens for an HTTP
Response. But Microsoft has already created such classes for you. On the
other hand, if you needed to create an FTP client, which Microsoft has NOT
provided, you could start with a Socket and go from there, building your own
properties and methods to send and receive FTP proptocol messages over a TCP
port.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.

"Aaron" <kuya789@.yahoo.com> wrote in message
news:O56fHf%23QFHA.2348@.tk2msftngp13.phx.gbl...
> tcpclient socket webrequest
>
> what are each used for? I read some reference books and did some research
> on the internet, but I'm still confused.
> could someone clarify this for me?
>
> Thanks,
> Aaron
thank you.

i always thought the ftp protocal was built on tcp. so i need to use sockets
instead of tcpclient?

is there anything lower than sockets?
what is the lowest level .Net can access? what about C/native unmanged?

Aaron

"Kevin Spencer" <kevin@.DIESPAMMERSDIEtakempis.com> wrote in message
news:ebCq0mBRFHA.164@.TK2MSFTNGP12.phx.gbl...
> Hi Aaron,
> Basically, you're lloking at similar types of classes for different levels
> of network communication.
> A Socket is a class for any type of network connection. It is a low-level,
> generic class for sending and receiving data over a network, and can work
> with virtually any type of protocol.
> A TCPClient is a higher-level class for working with the TCP protocol. It
> has a Socket (protected Client property) that does the actual connection,
> and has properties and methods for communicating via the TCP protocol.
> A WebRequest is a higher-level class for sending an HTTP Request over a
> TCP connection. It contains properties and methods for sending an HTTP
> Request, as well as properties and methods for receiving the HTTP Response
> that comes back.
> These are an excellent example of how Microsoft provides programming tools
> of virtually any level necessary to perform development tasks. For
> example, you could write your own TCP Client class by creating a class
> that uses a Socket to connect to a TCP port. You could further extend that
> class by creating a class that sends an HTTP Request and listens for an
> HTTP Response. But Microsoft has already created such classes for you. On
> the other hand, if you needed to create an FTP client, which Microsoft has
> NOT provided, you could start with a Socket and go from there, building
> your own properties and methods to send and receive FTP proptocol messages
> over a TCP port.
> --
> HTH,
> Kevin Spencer
> Microsoft MVP
> .Net Developer
> What You Seek Is What You Get.
> "Aaron" <kuya789@.yahoo.com> wrote in message
> news:O56fHf%23QFHA.2348@.tk2msftngp13.phx.gbl...
>> tcpclient socket webrequest
>>
>>
>> what are each used for? I read some reference books and did some research
>> on the internet, but I'm still confused.
>> could someone clarify this for me?
>>
>>
>> Thanks,
>> Aaron
>>
> is there anything lower than sockets?
> what is the lowest level .Net can access? what about C/native unmanged?

Yes, there is PLENTY lower than Sockets. As for the lowest level that .Net
can access, I would have to guess Assembler (not MSIL - Assembler), as C
allows inline Assembler, C++ is a superset of C, and C# allows inline C++
(unsafe/unmanaged). On the other hand, I wouldn't know for sure, as I
haven't had occasion to use Assembler for many years!

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.

"Aaron" <kuya789@.yahoo.com> wrote in message
news:utp4WTERFHA.3336@.TK2MSFTNGP09.phx.gbl...
> thank you.
> i always thought the ftp protocal was built on tcp. so i need to use
> sockets instead of tcpclient?
> is there anything lower than sockets?
> what is the lowest level .Net can access? what about C/native unmanged?
> Aaron
> "Kevin Spencer" <kevin@.DIESPAMMERSDIEtakempis.com> wrote in message
> news:ebCq0mBRFHA.164@.TK2MSFTNGP12.phx.gbl...
>> Hi Aaron,
>>
>> Basically, you're lloking at similar types of classes for different
>> levels of network communication.
>>
>> A Socket is a class for any type of network connection. It is a
>> low-level, generic class for sending and receiving data over a network,
>> and can work with virtually any type of protocol.
>>
>> A TCPClient is a higher-level class for working with the TCP protocol. It
>> has a Socket (protected Client property) that does the actual connection,
>> and has properties and methods for communicating via the TCP protocol.
>>
>> A WebRequest is a higher-level class for sending an HTTP Request over a
>> TCP connection. It contains properties and methods for sending an HTTP
>> Request, as well as properties and methods for receiving the HTTP
>> Response that comes back.
>>
>> These are an excellent example of how Microsoft provides programming
>> tools of virtually any level necessary to perform development tasks. For
>> example, you could write your own TCP Client class by creating a class
>> that uses a Socket to connect to a TCP port. You could further extend
>> that class by creating a class that sends an HTTP Request and listens for
>> an HTTP Response. But Microsoft has already created such classes for you.
>> On the other hand, if you needed to create an FTP client, which Microsoft
>> has NOT provided, you could start with a Socket and go from there,
>> building your own properties and methods to send and receive FTP
>> proptocol messages over a TCP port.
>>
>> --
>> HTH,
>>
>> Kevin Spencer
>> Microsoft MVP
>> .Net Developer
>> What You Seek Is What You Get.
>>
>> "Aaron" <kuya789@.yahoo.com> wrote in message
>> news:O56fHf%23QFHA.2348@.tk2msftngp13.phx.gbl...
>>> tcpclient socket webrequest
>>>
>>>
>>> what are each used for? I read some reference books and did some
>>> research on the internet, but I'm still confused.
>>> could someone clarify this for me?
>>>
>>>
>>> Thanks,
>>> Aaron
>>>
>>
>>

tcpclient socket webrequest

tcpclient socket webrequest
what are each used for? I read some reference books and did some research on
the internet, but I'm still .
could someone clarify this for me?
Thanks,
AaronHi Aaron,
Basically, you're lloking at similar types of classes for different levels
of network communication.
A Socket is a class for any type of network connection. It is a low-level,
generic class for sending and receiving data over a network, and can work
with virtually any type of protocol.
A TCPClient is a higher-level class for working with the TCP protocol. It
has a Socket (protected Client property) that does the actual connection,
and has properties and methods for communicating via the TCP protocol.
A WebRequest is a higher-level class for sending an HTTP Request over a TCP
connection. It contains properties and methods for sending an HTTP Request,
as well as properties and methods for receiving the HTTP Response that comes
back.
These are an excellent example of how Microsoft provides programming tools
of virtually any level necessary to perform development tasks. For example,
you could write your own TCP Client class by creating a class that uses a
Socket to connect to a TCP port. You could further extend that class by
creating a class that sends an HTTP Request and listens for an HTTP
Response. But Microsoft has already created such classes for you. On the
other hand, if you needed to create an FTP client, which Microsoft has NOT
provided, you could start with a Socket and go from there, building your own
properties and methods to send and receive FTP proptocol messages over a TCP
port.
HTH,
Kevin Spencer
Microsoft MVP
.Net Developer
What You S Is What You Get.
"Aaron" <kuya789@.yahoo.com> wrote in message
news:O56fHf%23QFHA.2348@.tk2msftngp13.phx.gbl...
> tcpclient socket webrequest
>
> what are each used for? I read some reference books and did some research
> on the internet, but I'm still .
> could someone clarify this for me?
>
> Thanks,
> Aaron
>
thank you.
i always thought the ftp protocal was built on tcp. so i need to use sockets
instead of tcpclient?
is there anything lower than sockets?
what is the lowest level .Net can access? what about C/native unmanged?
Aaron
"Kevin Spencer" <kevin@.DIESPAMMERSDIEtakempis.com> wrote in message
news:ebCq0mBRFHA.164@.TK2MSFTNGP12.phx.gbl...
> Hi Aaron,
> Basically, you're lloking at similar types of classes for different levels
> of network communication.
> A Socket is a class for any type of network connection. It is a low-level,
> generic class for sending and receiving data over a network, and can work
> with virtually any type of protocol.
> A TCPClient is a higher-level class for working with the TCP protocol. It
> has a Socket (protected Client property) that does the actual connection,
> and has properties and methods for communicating via the TCP protocol.
> A WebRequest is a higher-level class for sending an HTTP Request over a
> TCP connection. It contains properties and methods for sending an HTTP
> Request, as well as properties and methods for receiving the HTTP Response
> that comes back.
> These are an excellent example of how Microsoft provides programming tools
> of virtually any level necessary to perform development tasks. For
> example, you could write your own TCP Client class by creating a class
> that uses a Socket to connect to a TCP port. You could further extend that
> class by creating a class that sends an HTTP Request and listens for an
> HTTP Response. But Microsoft has already created such classes for you. On
> the other hand, if you needed to create an FTP client, which Microsoft has
> NOT provided, you could start with a Socket and go from there, building
> your own properties and methods to send and receive FTP proptocol messages
> over a TCP port.
> --
> HTH,
> Kevin Spencer
> Microsoft MVP
> .Net Developer
> What You S Is What You Get.
> "Aaron" <kuya789@.yahoo.com> wrote in message
> news:O56fHf%23QFHA.2348@.tk2msftngp13.phx.gbl...
>
> is there anything lower than sockets?
> what is the lowest level .Net can access? what about C/native unmanged?
Yes, there is PLENTY lower than Sockets. As for the lowest level that .Net
can access, I would have to guess Assembler (not MSIL - Assembler), as C
allows inline Assembler, C++ is a superset of C, and C# allows inline C++
(unsafe/unmanaged). On the other hand, I wouldn't know for sure, as I
haven't had occasion to use Assembler for many years!
HTH,
Kevin Spencer
Microsoft MVP
.Net Developer
What You S Is What You Get.
"Aaron" <kuya789@.yahoo.com> wrote in message
news:utp4WTERFHA.3336@.TK2MSFTNGP09.phx.gbl...
> thank you.
> i always thought the ftp protocal was built on tcp. so i need to use
> sockets instead of tcpclient?
> is there anything lower than sockets?
> what is the lowest level .Net can access? what about C/native unmanged?
> Aaron
> "Kevin Spencer" <kevin@.DIESPAMMERSDIEtakempis.com> wrote in message
> news:ebCq0mBRFHA.164@.TK2MSFTNGP12.phx.gbl...
>