Questions tagged [tcpclient]

.NET Framework class, providing client connections for TCP network services.

2541 questions
13
votes
1 answer

When to use TcpClient.ReceiveTimeout vs. NetworkStream.ReadTimeout?

When programming a TCP server I would like to set the timeout period for reading the request from the client: var tcpClient = tcpListener.AcceptTcpClient(); var networkStream = tcpListener.GetStream(); tcpClient.ReceiveTimeout =…
Dio F
  • 2,458
  • 1
  • 22
  • 39
13
votes
1 answer

AuthenticateAsClient: System.IO.IOException: Received an unexpected EOF or 0 bytes from the transport stream

Due to Heartbleed, our Gateway Server was updated and this problem presented itself. Due to POODLE, SSLv3 is no longer supported. Note, the problem is only present on Win7+ boxes; WinXP boxes work without issue (same code, different OS = problem);…
Bret
  • 2,283
  • 4
  • 20
  • 28
13
votes
2 answers

Is it possible to convert between Socket and TcpClient objects?

Here's another C#/.NET question based merely on curiousity more than an immediate need ... If you had a Socket instance and you wanted to wrap it in the higher-level TcpClient class, is that possible and how would you do it? Conversely if you have…
Neil C. Obremski
  • 18,696
  • 24
  • 83
  • 112
13
votes
1 answer

EOF in async_read() in boost::asio

When the async_read_some() returns an exception of EOF does it mean the server stopped sending data or does it mean the connection is closed. I'm having this confusion as I cant find a method to know if the client has received all data from server.
Jishnu U Nair
  • 512
  • 5
  • 12
  • 29
12
votes
4 answers

Loop until TcpClient response fully read

I have written a simple TCP client and server. The problem lies with the client. I'm having some trouble reading the entire response from the server. I must let the thread sleep to allow all the data be sent. I've tried a few times to convert this…
jim
  • 8,670
  • 15
  • 78
  • 149
12
votes
0 answers

tcp_input [C5.1:3] flags=[R.] seq=2934102331

My console prints this randomly multiple times, where do i begin looking where the issue originates? The app works fine apart from this print appearing? tcp_input [C5.1:3] flags=[R.] seq=2934102331, ack=920253567, win=1024 state=LAST_ACK…
user13209952
12
votes
8 answers

TcpClient.GetStream().DataAvailable returns false, but stream has more data

So, it would seem that a blocking Read() can return before it is done receiving all of the data being sent to it. In turn we wrap the Read() with a loop that is controlled by the DataAvailable value from the stream in question. The problem is that…
James
  • 1,651
  • 2
  • 18
  • 24
11
votes
2 answers

asyncio server and client to handle input from console

I have an asyncio TCP server that take messages from client, do stuff() on server and sends texts back. Server works well in the sense that receives and sends data correctly. Problem is that I can't takes messages back from server in the client…
BangTheBank
  • 809
  • 3
  • 11
  • 26
11
votes
5 answers

What happens if you break out of a Lock() statement?

I'm writing a program which listens to an incoming TcpClient and handles data when it arrives. The Listen() method is run on a separate thread within the component, so it needs to be threadsafe. If I break out of a do while loop while I'm within a…
dlras2
  • 8,416
  • 7
  • 51
  • 90
11
votes
2 answers

Why does NetworkStream Read like this?

I have an application that sends messages that are newline terminated over a TCP socket using TCPClient and it's underlying NetworkStream. The data is streaming in at roughly 28k every 100ms from a realtime data stream for monitoring. I've stripped…
paquetp
  • 1,639
  • 11
  • 19
11
votes
1 answer

Specify the outgoing IP address to use with TCPClient / Socket in C#

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…
Dave Hogan
  • 3,201
  • 6
  • 29
  • 54
11
votes
2 answers

Android TCP connection best practice

I am working on an Android application that requires a TCP connection to a TCP server(Written in Node.js) My Android TCP client is working an can send messages back and forth. My spesific questions is: What is the best way to handle a TCP…
Emil
  • 146
  • 1
  • 1
  • 5
10
votes
3 answers

What conditions cause NetworkStream.Write to block?

Will NetworkStream.Write block only until it places the data to be sent into the TCP send buffer, or will it block until the data is actually ACK'd by the receiving host? Note: The socket is configured for blocking I/O. Edit: Whoops, there's no such…
David Pfeffer
  • 38,869
  • 30
  • 127
  • 202
10
votes
1 answer

Faster way to communicate using TcpClient?

I'm writing a client/server application in C#, and it's going great. For now, everything works and it's all pretty robust. My problem is that I run into some delays when sending packets across the connection. On the client side I'm doing…
ReturningTarzan
  • 1,068
  • 1
  • 13
  • 23
10
votes
1 answer

C# - an established connection was aborted by the software in your host machine Error

I am building a Mock Server using TCPListener. When I tried to debug my code by running the client, I was able to read the request on the server. But on the client side, an exception is being thrown. Here is the exception I got from the…
Ray
  • 627
  • 1
  • 7
  • 19