Hi,
I am trying to use
private TcpClient tcpClient;
in a class and every time when I send a command like LIST, RETR, STOR, I used to lock the TCPClient for that particular time of execution of commands and getting response.
Now when I send the other command in between the one is executing, It isn't able to lock that tcpclient instan...
We are using HttpURLConnection API to invoke a REST API to the same provider often (kind of an aggregation usecase). We want to keep a pool of 5 connections always open to the provider host (always the same IP).
What is the proper solution? Here is what we tried:
System.setProperty("http.maxConnections", 5); // set globally only once...
after the connection has been established, and the two sides have no communication, which timeout value determins the idle connection be closed?
...
I have a class that inherits from TcpClient. In that class I have a method to process responses. In that method I call I get the NetworkStream with MyBase.GetStream and call Read on it.
This works fine, excpet the first call to read blocks too long. And by too long I mean that the socket has recieved plenty of data, but won't read it un...
I have a class that handles TcpClients. What the class should do is:
while the other end has not done a graceful close or we are stopping
{
receive a request
process it
send response
}
As I don't know when the other client will send a request I can not do a Read with a timeout set, so what I have un...
Here's my situation:
I'm writing a chat client to connect to a chat server. I create the connection using a TcpClient and get a NetworkStream object from it. I use a StreamReader and StreamWriter to read and write data back and forth.
Here's what my read looks like:
public string Read()
{
StringBuilder sb = new StringBuilder();
try...
With regards to handling a TCP/IP connection using the TcpClient class, is there an alternative for checking whether the remote host has closed the connection other than waiting for the NetworkStream.Read method to return a 0?
...
C# has several useful classes for networking tasks such as TcpClient and WebClient. Both have BeginX methods (BeginConnect and BeginGetResponse respectively) that according to MSDN should always be followed by EndX. Both accepts a delegate that is called once the operation is complete.
However, say we fail to establish a connection, and...
I've a server with several IP Addresses assigned to the network adapter.
On that server is a client app to connect to another server app via TCPClient. For all outgoing communications my servers default IP address is being used, however for this one application I'd like the outgoing communication to be send out on another local IP addre...
I've written a simple chat program to experiment with some basic tcp/socket concepts. For some reason I've found that when I close my writer stream (which I am getting from the TcpClient.GetStream() function) it will send one final null message to my server. To top it all off it doesn't do this if I send one final message over the stream...
how to add in exception showing the input has to be enter, if the user click on connect without entering any input? i would like the have a message box show if the user click on the connect button without entering the name, ip and port. [SOLVED]
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System....
I'm trying con build a simple chat client/software (whole in on executable) wich start listen from the start on the port 5900 and when a client connect to that port the chat is established.
The problem is that only the client can chat to the server, the server cannot answer the client because the connection is working in one way.
The i...
Can anyone point out the flaw in this code? I'm retrieving some HTML with TcpClient. NetworkStream.Read() never seems to finish when talking to an IIS server. If I go use the Fiddler proxy instead, it works fine, but when talking directly to the target server the .read() loop won't exit until the connection exceptions out with an error l...
Why won't the following code work in C#?
var c1 = new TcpClient(new IPEndPoint(IPAddress.Any, 8787));
var c2 = new TcpClient(new IPEndPoint(IPAddress.Any, 8788));
c1.Connect("localhost", 8788);
I get a "connection cannot be made because the target machine actively refused it". So, the TcpClient constructor doesn't appear to be binding...
Hi All,
I know the similar question may have been asked many times, but I want to represent the behavior I'm seeing and find if somebody can help predict the cause of this.
I am writing a windows service which connects to other windows service over TCP.
There are 100 user entities of this, and 5 connections per each. These users perfor...
Hello All.
I tried to send/receive data by using TcpClient. I did two experiments and found something interesting.
I setup the TcpListener in a server in Japan and the TcpClient in UK. I kept sending 500 bytes to the TcpListener and when TcpListener sends 10KB back to the TcpClient. I kept this send/receive looping for 500 times in eac...
A customer has asked that we do a dynamic whois lookup on the homepage of their ASP.NET site, based on the IP of the user accessing the site.
The implementation would be something like what's described here:
http://www.aspheute.com/english/20000825.asp
However, I noticed that this code connects to whois.networksolutions.com. I am thin...
Just as the title says:
How can TcpClient implement IDisposable and not have a public Dispose method?
...
In my C# application, I have a thread which basically continually reads from a TcpClient until told to stop. I use WaitHandles for this purpose, for example:
private ManualResetEvent stopping;
private void Receive()
{
while (!this.stopping.WaitOne(10))
{
while (this.client.Available > 0)
{
// Read an...